Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/goldenhub/fullstackopen-part4
Implementing a standard node directory structure in a simple POST and GET blog app
https://github.com/goldenhub/fullstackopen-part4
cors dotenv eslint expressjs middlewares mongodb mongodb-atlas mongoose-schema mongoose-validation mongoosejs nodejs nodemon
Last synced: about 1 month ago
JSON representation
Implementing a standard node directory structure in a simple POST and GET blog app
- Host: GitHub
- URL: https://github.com/goldenhub/fullstackopen-part4
- Owner: Goldenhub
- License: mit
- Created: 2022-10-25T22:49:34.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-24T02:08:38.000Z (11 months ago)
- Last Synced: 2024-01-24T03:27:28.705Z (11 months ago)
- Topics: cors, dotenv, eslint, expressjs, middlewares, mongodb, mongodb-atlas, mongoose-schema, mongoose-validation, mongoosejs, nodejs, nodemon
- Language: JavaScript
- Homepage:
- Size: 204 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Simple Bloglist Node App
## implementing standard node directory struture
### Dependencies
- express
- mongoose
- dotenv
- cors### Dev Dependencies
- eslint
- nodemon## Directory structure
```javascript
├── index.js
├── app.js
├── controllers
│ ├──blogs.js
├── package-lock.json
├── package.json
├── utils
├── config.js
├── logger.js
└── middleware.js
├── models
├── blog.js
```## How to run
- Clone the repo
- Run `npm install`
- Run `npm run dev` to start the server with nodemon
- Run `npm start` to start the server without nodemon
- Use Postman or any Rest Client to test the endpoints- ```javascript
// GET all blogs
GET http://localhost:3003/api/blogs
// POST a blog
POST http://localhost:3003/api/blogs
{
"title": "Blog Title",
"author": "Blog Author",
"url": "Blog URL",
"likes": 0
}
```### Note
- The server will run in PORT 3003 by default. You can set the PORT in your .env file.
- MongoDB database was used for this project. You can set the MONGODB_URI in your .env file.## How to lint
- Run `npm run lint`