Skip to content

example clean Node.js REST API with Fastify framework and MongoDB

License

Notifications You must be signed in to change notification settings

sophiabrandt/fastify-bookmarkly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MIT License

fastify-bookmarkly

Table of Contents

About

fastify-bookmarkly is an example backend API using the Fastify framework, MongoDB, and a clean architecture.

Parts of the original code are from Bill Sourour's DevMastery Comments Microservice API and Clean RESTful API with Node.js.

The project is a learning repository where I explore how to code a "clean" Node API from scratch.

Built With

  • Node.js & Fastify
  • Docker & Docker Compose
  • MongoDB

Installation

Prerequisites:

1. Clone the repository:

$ git clone [email protected]:sophiabrandt/fastify-bookmarkly.git && cd fastify-bookmarkly

2. Adjust configuration

Check the config folder and change the name of variables as needed.

3. Install dependencies

$ pnpm install # or npm install

4. Use Docker and Docker Compose to spin up the Mongo Database

$ docker-compose up -d

5. Create Database schema

$ pnpm run db # or npm run db

Usage

$ pnpm run dev # or npm run dev

Visit http://localhost:3000/bookmarks with your browser.

Swagger documentation is available under http://localhost:3000/docs.

Example request with curl:

curl -X POST \
  'http://127.0.0.1:3000/bookmarks/' \
  -H 'Content-Type: application/json' \
  -d '{"title": "hacker news", "description": "news for programmers", "url": "https://hackerweb.app"}'

To create a production build:

$ pnpm run build # or npm run build
$ pnpm run start # or npm run start

Tests

$ pnpm run test # or npm run test

For now, the tests contain stubs, but are are already connected to MongoDB.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

Copyright © 2020 Sophia Brandt
MIT Licence

Acknowledgments

About

example clean Node.js REST API with Fastify framework and MongoDB

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published