This ExpressJS template provides the basic infrastructure for a JSON API with MongoDB persistency with Mongoose.
| File | Purpose | What you do? |
|---|---|---|
| README.md | Everything about the server | READ ME carefully! |
| app.js | JavaScript entry point for Express application | Import new routes/controllers |
controllers/ |
Implementation of Express endpoints | Define new route handlers |
models/ |
Mongoose models | Define data schema |
| tests/server.postman_collection.json | Postman test scripts | Replace with your exported Postman test collection |
| docs/FAQ.md | List of FAQs | Find answers to common questions |
| docs/TROUBLESHOOTING.md | List of problems and solutions | Find solutions for common error messages |
| package.json | Project meta-information | — |
NOTE: The (mandatory) exercises are essential for understanding this template and will save you time!
Optional: Learn how to create such a project template in this tutorial.
Make sure, you are in the server directory cd server
Installs all project dependencies specified in package.json.
npm install
Automatically restarts your server if you save any changes to local files.
npm run dev
npm start
Starts a new server on another port (default 3001) and runs the server postman test collection against a test database (default serverTestDB).
npm test
The test database is dropped before each test execution. Adjust your tests to support this clean state.
We use the API testing tool Postman to define example HTTP requests and test assertions. Your tests will be automatically executed in GitLab pipelines whenever you push to the master branch. Try to do that as often as possible.
Remember to export and commit any test changes back to
tests/server.postman_collection.jsonand make surenpm testsucceeds for your final submission!
Learn more in the VSCode Debugging Docs.