Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/smakosh/rest-api-boilerplate-v2
Boilerplate of a RESTful API
https://github.com/smakosh/rest-api-boilerplate-v2
express mongoose nodejs rest-api
Last synced: 12 days ago
JSON representation
Boilerplate of a RESTful API
- Host: GitHub
- URL: https://github.com/smakosh/rest-api-boilerplate-v2
- Owner: smakosh
- Created: 2018-07-15T21:31:04.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-05-09T19:13:07.000Z (over 3 years ago)
- Last Synced: 2024-10-17T16:07:39.519Z (22 days ago)
- Topics: express, mongoose, nodejs, rest-api
- Language: JavaScript
- Homepage:
- Size: 284 KB
- Stars: 31
- Watchers: 3
- Forks: 11
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Setup
npm i
Before running anything locally, create a `.env` file and initialize your env variable like so:
DB=mongodb://localhost:27017/boilerplate
SECRET_KEY=NSA
REACT_APP_URL=http://localhost:3000 // when cors is enabled, this will be the only origin to send requestsPS: if you're deploying to a VPS/VPC u should have another `.env.production` file and add some logic to handle that on the `./config/config.js` file.
Start the db locally
npm run database
PS: replace `mongo-data` with the name of the folder your data is stored.
start dev server
npm run dev
start prod server
npm start
## Models
User
- firstName
- lastName
- username
- password
- tokensProfile
- user
- type
- handle
- datePost
- title
- description
- date
- _creator## Routes
- User
POST /api/user/register
// Register a new user and returns user data with the generated token
// PublicPOST /api/user/login
// Login user and returns user data with the generated token
// PublicGET /api/user/verify
// Verifies token and returns current user data
// PrivateDELETE /api/user/logout
// Logout
// Private- Profile
GET /api/profile
// GET current user profile
// PrivatePOST /api/profile
// create or Edit user profile
// PrivateDELETE /api/profile
// Delete user and profile
// PrivateGET /api/profile/all // Not available yet
// Get all profilesGET /api/profile/handle/:handle // Not available yet
// Get profile by handle- Post
POST /api/post
// Create a new post
// PrivateGET /api/post/all
// Get all the postsGET /api/post/:id
// Get Post by ID
// PrivateDELETE /api/post/:id
// Delete Post by ID
// PrivatePATCH /api/post/:id
// Update a post
// Private