An open API service indexing awesome lists of open source software.

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

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