This is a Node.js template for the Acebook engineering project.
It uses:
- Express web framework for Node.js.
- Nodemon to reload the server automatically.
- Handlebars to render view templates.
- Mongoose to model objects in MongoDB.
- ESLint for linting.
- Jest for testing.
- Cypress for end-to-end testing.
-
Install Node Version Manager (NVM)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh | bash
-
Open a new terminal
-
Install the latest long term support (LTS) version of Node.js.
nvm install --lts
- Fork this repository into the sub-group for your cohort (it should be a sub-group of
makers-students
and be named something likeyour-cohort-name-students
). - Rename your fork to
acebook-<team name>
- Clone your fork to your local machine
- Install Node.js dependencies
npm install
Gyp error on npm install?
If you're getting the following error:
AttributeError: module 'collections' has no attribute 'MutableSet'
Error: `gyp` failed with exit code: 1
try installing this package separately before running `npm install`:
npm --build-from-source install node-pre-gyp
- Install an ESLint plugin for your editor. For example: VSCode ESLint for Atom.
- Start a MongoDB database using Docker
; docker run -p 27017:27017 mongo # Or in the background ; docker run -d -p 27017:27017 mongo # And if you want to connect to it via the CLI ; brew install mongosh ; mongosh
- Start the server
; npm start
- Browse to http://localhost:3000
- Run all tests
; npm run start:test
# And then, in another terminal...
; npm test
- Run a check
npm run lint # linter only
npm run test:unit # unit tests only
npm run test:integration # integration tests only
The server must be running locally with test configuration for the
integration tests to pass.
; npm run start:test
This starts the server on port 3030
and uses the acebook_test
MongoDB database,
so that integration tests do not interact with the development server.
If you're new to using Node, you may be wondering where all of these commands above are defined.
Have a look at the scripts
section of the package.json
file in this repo.
It'll help with your understanding of what is going on in the .gitlab-ci.yml
file.