Forum is nodejs express backend project that allow user to sign up and sign in so they can perform the ###CRUD operations.
Follow these instructions to run the project on your local machine.
Make sure you have node -v 10 and above installed or follow this link to install it :point_right: Install Nodejs
These are steps to clone the repository
- open your terminal (
cmd
,git bash
or whatever you have ).- Dive into the location you want to put your local repository.
- Then run this command 👇
$ git clone https://github.com/GolgothaAksanti/forum.git
Install all dependencies so you can run the project
$ npm install
Create a
.env
file where you are going to set all environment variables from a.env.sample
file in the root
Make sure your
.env
variables are well set then run this command :point_right:$ npm run db:create
⚠️ Run this command after creating the database 👉$ npm run db:migrate
⚠️ You don't have to run this command but just in case you want to delete your database 👉$ npm run db:drop
After Installing dependencies, creating database and migrating models(tables) you can now run the server safely by typing this command :point_right:
$ npm run dev
Make sure your
.env
variables are well set then run this command :point_right:$ npm run db:create:test
⚠️ Run this command after creating the database 👉$ npm run db:migrate:test
⚠️ You don't have to run this command but just in case you want to delete your database 👉$ npm run db:drop:test
creating database and migrating models(tables) for test, you can now run the test by typing this command :point_right:
$ npm test
You can collect the coverage report by typing this command :point_right:
$ npm run coverage
You can type this command 👇 to test the code style with
eslint
$ npm run lint
and fix your code style with eslint by typing this command :point_right:$ npm run lint:fix
This project is using advanced javascript (es5 and above version) for transpiling it you have to build it so it can be faster to do so you have to run the command below 👇
$ npm run build
then 👇$ npm start
- src
- app
- controllers
- blogControllers.js
- userController.js
- helpers
- extractToken.js
- jwtHelper.js
- responseHandler.js
- userChema.js
- utils.js
- middlewares
- asyncHandler.js
- validator.js
- routes
- auth
-index.js
- blog
- index.js
- app.js
- database
- config
- config.js
- migrations
- user-migration.js
- blog-migration.js
- models
- user.js
- blog.js
- index.js
- services
- userService.js
- blogService.js
- extends
- mocks
- dummyData.js
- variables.js
- tests
- core.test.js
- user.test.js
- blog.test.js
- server.js
Method | Endpoint | Public | Action |
---|---|---|---|
POST | /auth/signup | True | User Signup |
POST | /auth/signin | True | User Signin |
Method | Endpoint | Public | Action |
---|---|---|---|
POST | /blog/posts | False | Create a blog |
GET | /blog/posts | True | Get all blogs |
GET | /blog/posts/:post_id | True | Get a single blog |
PUT | /blog/posts/:post_id | False | Update blog |
DELETE | /blog/posts/:post_id | False | Delete blog |