Most of freecodecamp's certificate tests need a simple codepen work. But, from backend development and apis section, it needs a user to configure a whole project and build using gitpod, online tool.
This post is for freecodecamp's backend development and apis projects. Freecodecamp's backend development and apis project consists of 5 microservice projects like following:
- Timestamp Microservice
- Request Header Parser Microservice
- URL Shortener Microservice
- Exercise Tracker
- File Metadata Microservice
Of course these projects are not difficult to the users who took the all courses that freecodecamp provides.
But I created a node.js project for freecodecamp's backend development and apis projects to help developers to understand and pass more easily.
To simplify, I integrated 5 projects into one express projects using router.
Unfortunately, as those projects have some same api endpoints, you should activate and run one by one separately.
Structure of the project is following:
- models folder: includes two mongoose models for exercise tracker microservice project(fourth project)
- routes folder: includes 6 express router files(five for individual projects and one for home)
- public folder:** contains data.json(for third, url shortener project) and style.css(I didn't care about styles, as it is for backend api functions).
- uploads folder: it is for last project(file metadata microservice)
- views folder: includes 5 index.html files(each one for each project)
- app.js: main express app file(you will work here mostly)
- server.js: main endpoint file for node project
For example, if you build and run the project for "URL Shortener Microservice", third task, you should do like following:
- First, in app.js file, change the home page into views/index3.html and uncomment require statement for express router(urlShortener in this case) and app.use statement with that router.
app.get('/', function(req, res) {
res.sendFile(process.cwd() + '/views/index1.html');
});
const home = require('./routes/homeRoute');
// const timestamp = require('./routes/timestampRoute');
// const headerParser = require('./routes/headerParserRoute');
const urlShortener = require('./routes/urlShortenerRoute');
// const exTracker = require('./routes/exTrackerRoute');
// const metadataRouter = require('./routes/metadataRoute');
app.use('/api', home);
// app.use('/api', timestamp);
// app.use('/api', headerParser);
app.use('/api', urlShortener);
// app.use('/api', exTracker);
// app.use('/api', metadataRouter);
- Second, build and run the project.
npm run start
For other projects, do the same thing as above.
Here are running screens for each project.
- Timestamp Microservice project
- Request Header Parser Microservice project
- URL Shortener Microservice project
- Exercise Tracker project
- File Metadata Microservice project
You can download full codebase from my git repository.
I hope it would be helpful to you.
Top comments (0)