Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
"airbnb-typescript/base",
"plugin:import/typescript"
],
"ignores": ["./**"],
"ignorePatterns": ["./webpack.config.js"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module",
"ecmaVersion": "latest",
"sourceType": "commonjs",
"project": "./tsconfig.json"
},
"plugins": ["react", "@typescript-eslint"],
Expand Down
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "trailingComma": "es5", "tabWidth": 4, "semi": false, "singleQuote": true }
{ "trailingComma": "es5", "tabWidth": 2, "semi": true, "singleQuote": true }
82 changes: 82 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# CRUD API

A simple CRUD (Create, Read, Update, Delete) API for managing users, built with TypeScript and Node.js.

## Features

- Create, read, update, and delete users.
- Simple and intuitive API structure.
- Handles various HTTP methods with appropriate responses.

## Installation

1. Clone the repository:

```bash
git clone https://github.com/jpaberzs/CRUD_API.git
cd CRUD_API
```

2. Install the dependencies:

```bash
npm install
```

3. Create a .env file in the root directory and set the port:

```plaintext
PORT=4000
```

## Usage

To start the development server, run:

```bash
npm run start:dev
```
To start the production server, run:

```bash
npm run start:prod
```
To start multi server, run:

```bash
npm run start:multi
```

## API Endpoints
User Routes

- GET /api/users - Retrieve all users
- GET /api/users/:userId - Retrieve a user by ID
- POST /api/users - Create a new user
- PUT /api/users/:userId - Update an existing user by ID
- DELETE /api/users/:userId - Delete a user by ID

Response Codes

- 200 OK - Successful operation
- 201 Created - User successfully created
- 204 No Content - User successfully deleted
- 400 Bad Request - Invalid user ID or data
- 404 Not Found - User not found

## Scripts

- start:prod: Build and start the production server.
- start:dev: Start the development server with TypeScript support using ts-node.
- start:multi: Start the development server with multiple ports and TypeScript support using ts-node.

## Technology Stack

- Node.js - JavaScript runtime for building the API.
- TypeScript - For static typing and modern JavaScript features.
- webpack - Module bundler for building the project.


## License

This project is licensed under the ISC License.
16 changes: 16 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,24 @@ import pluginJs from '@eslint/js';
import tseslint from 'typescript-eslint';

export default [
{
env: {
browser: true,
es2021: true,
jest: true,
},
},
{ files: ['**/*.{js,mjs,cjs,ts}'] },
{ languageOptions: { globals: globals.browser } },
{
extends: [
'next/core-web-vitals',
'next/typescript',
'airbnb-typescript/base',
'plugin:import/typescript',
],
},
{ ignores: ['webpack.config.js'] },
pluginJs.configs.recommended,
...tseslint.configs.recommended,
];
9 changes: 9 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { Config } from 'jest';

const config: Config = {
preset: 'ts-jest',
testEnvironment: 'node',
testMatch: ['**/__tests__/**/*.+(ts|js)'],
};

export default config;
Loading