https://github.com/tomdieu/nodejs-and-express-crud
Nodejs and express CRUD operation using sequelize ORM
https://github.com/tomdieu/nodejs-and-express-crud
crud-api express nodejs sequelize-orm sequelizejs sqlite3
Last synced: about 2 months ago
JSON representation
Nodejs and express CRUD operation using sequelize ORM
- Host: GitHub
- URL: https://github.com/tomdieu/nodejs-and-express-crud
- Owner: Tomdieu
- Created: 2022-10-28T18:39:26.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-10-29T22:11:43.000Z (over 3 years ago)
- Last Synced: 2025-03-23T21:31:51.324Z (over 1 year ago)
- Topics: crud-api, express, nodejs, sequelize-orm, sequelizejs, sqlite3
- Language: JavaScript
- Homepage:
- Size: 51.8 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# nodejs-and-express-crud
## How to execute
install dependencies
navigate to the folder
```
cd nodejs-and-express-crud/
```
install the dependecies with
```
npm install --save
```
## run with
```
npm start
```
## Routes
- GET `http://localhost:5000/users` to view all the users
`http://localhost:5000/users`
## Response
```json
{
"users": [
{
"id": 1,
"name": "ivantom",
"age": 10,
"createdAt": "2022-10-29T21:43:37.588Z",
"updatedAt": "2022-10-29T21:43:37.588Z"
},
{
"id": 3,
"name": "test_user",
"age": 14,
"createdAt": "2022-10-29T21:45:56.111Z",
"updatedAt": "2022-10-29T21:56:16.320Z"
}
]
}
```
- GET `http://localhost:5000/users/:id` to view a user
## Example
`http://localhost:5000/users/1`
## Response
```json
{
"id": 1,
"name": "ivantom",
"age": 10,
"createdAt": "2022-10-29T21:43:37.588Z",
"updatedAt": "2022-10-29T21:43:37.588Z"
}
```
- POST `http://localhost:5000/users` to add a user
`http://localhost:5000/users`
## input
```json
{
"name":"tom",
"age":19
}
```
## Response
```json
{
"user": {
"name": "tom",
"age": 19
},
"message": "user created successfully!"
}
```
- DELETE `http://localhost:5000/users/:id` to delete a user
## Example
`http://localhost:5000/users/5`
## Response
```json
{
"msg": "User with id 5 deleted!"
}
```
- PATCH `http://localhost:5000/users/:id` to update a user
## Example
`http://localhost:5000/users/3`
## Form data
```json
{
"name":"test_user",
"age":19
}
```
## Response
```json
{
"msg": "User with the id 3 has been updated!",
"user": {
"id": 3,
"name": "test_user",
"age": 19,
"createdAt": "2022-10-29T21:45:56.111Z",
"updatedAt": "2022-10-29T21:56:16.320Z"
}
}
```