We’ll implement the backend that will serve the config for the gold mining game.
Our backend will be built on Express.js
, so let’s install it with npm install --save express
first.
Take a look at the files you have. We’ll be adding our routes to the server
constant in server.js
later.
For now, let’s create one more file functions.js
and export the function startServer(port, server)
The function startServer(port, server)
should call the server.listen(port, callback)
to start a server
You can include anything you like in the callback, i.e. console.log('Server is running on port' + port)
This task is part of the Full-Stack JavaScript Course.
If you have any issues with it, you can ask for community help below the post.
Feel free to help others if you’ve already solved the task.
index.js
// OUR GOLD MINING EMPIRE NEEDS A CONFIG!
server.js
import express from 'express';
const server = express();
//Here, we'll implement our routes and middleware
export { server };