A REST API built using Node.js, Express.js, In-memory MongoDB and Mongoose.
- Node.js v12.14.0 or higher
- yarn
-
You can also use npm, but the app was built using yarn and that is what the documentation will reflect.
-
- Express.js
- In-memory database using mongodb-memory-server
-
This database does not persist.
-
It's just there to get up and running quickly and for testig
-
- Interface with database with Mongoose
- Password hashing with bcrypt.js // Not yet impemented
- Cross Origin Request using cors
- Reading environment variables using dotenv
- Testing with Jest
- Dev server using nodemon
IMPORTANT: The MongoDB binaries will be downloaded to the node_modules directory the first time the server is ran. This may cause a delay in seeing a response from the database. This is done from the dev dependency
mongodb-memory-serverthat uses an in-memory database.
git clone https://github.com/ButlerFuqua/express_starter.git
cd express_starter
yarn
yarn dev
That's it!
The app should be listening at http://localhost:8080. Alternatively you can create a .env file in the root and assign a different port with the PORT variable.
NOTE: An environment variable named
PORTwill override the default port of8080
Run yarn start instead of yarn dev in a production environment. yarn dev listens for changes using nodemon.
Simply run yarn test from the root of the application to run the scripted tests.
The testing files can be found in the tests directory. Jest automatically runs all files with the .test.js extension.
srcapi- handle routes and middleware
database- connect to and seed database
models- model schema and database logic layer
services- business logic layer
validation- handle validation
- app.js - entry point of app
tests- contains jest tests
- jest-mongo-config - configuration for temp mongoDB used for testing
- jest-config - configuration file for testing
- package.json - app info, list of dependencies and scripts
- README.md - overview of app