https://github.com/moonwave99/crud-template
Crud operations overview
https://github.com/moonwave99/crud-template
Last synced: 8 months ago
JSON representation
Crud operations overview
- Host: GitHub
- URL: https://github.com/moonwave99/crud-template
- Owner: moonwave99
- Created: 2023-12-04T10:33:05.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-04T10:38:39.000Z (over 2 years ago)
- Last Synced: 2025-10-11T04:32:00.717Z (8 months ago)
- Language: JavaScript
- Size: 204 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CRUD Recap Project
This project is an app that renders services provided by users, and allows their editing, creation and removal.
## API Endpoints
They are organised in two files:
- `/pages/api/services/index.js`: for the operations relative to the **list** of all services;
- `/pages/api/services/[id].js`: for the operations relative to the **single** service.
| Method | URL | What it does |
|--------|-------------------|-----------------------|
| GET | /api/services | Gets all services |
| POST | /api/services | Creates new service |
| GET | /api/services/:id | Gets service by id |
| PUT | /api/services/:id | Edits service by id |
| DELETE | /api/services/:id | Deletes service by id |
## Pages
Paths are relative to the `/pages` folder.
| File | URL | What it does |
|-----------------------|--------------------|----------------------------------|
| index.js | / | Displays all services |
| new.js | /new | Displays the create service form |
| services/[id].js | /services/:id | Displays a service by given `id` |
| services/edit/[id].js | /services/edit/:id | Displays the edit service form |
## Development
### Local Development
First provide the MongoDB connection URL in the `.env.local` file:
```
MONGODB_URI=mongodb+srv://:@cluster0.tdm0q.mongodb.net/?retryWrites=true&w=majority
```
Then install the dependencies using `npm i`.
Run `npm run dev` to start a development server and open the displayed URL in a browser.
Use `npm run db:populate` to fill the db with some initial data.
### Scripts
You can use the following commands:
- `npm run dev` to start a development server
- `npm run build` to build the project
- `npm run start` to start a production server
- `npm run test` to run the tests
- `npm run lint` to run the linter
- `npm run db:populate` to populate the db with some fixtures