Skip to content

Latest commit

 

History

History
119 lines (83 loc) · 2.7 KB

README.md

File metadata and controls

119 lines (83 loc) · 2.7 KB

KOLLEGE API

MIT License

REST API for kollege

Setting Up

Clone the project:

  git clone https://github.com/iafthab/kollege_api.git

Change Directory:

  cd kollege_api

Install dependencies:

  npm install

Create a .env file and paste your MongoDB Database Key (reference video):

  DATABASE_URI = mongodb+srv:/username:password@.....mongodb.net/kollege
  // you can give a name of your preference to database instead of kollege

Start the server (node v.19+):

  npm run dev

Allowing requests without headers during development

Inside config/corsOptions.js, uncomment "|| !origin" part during development

 if (
      allowedOrigins.indexOf(origin) !== -1
      //! comment out/remove in production
       || !origin
    )

Adding HOD

Since admin isn't added yet - HOD manages most things.
You'll need to add an HOD manually.
🚀 Use a REST API client like Postman/Thunder Client.

Request Method: POST
Request Address: http://localhost:3500/staff
// the port should be where you host the server, 3500 by default, and not the react port i.e, 3000 Request Body:

  {
"name":"...",
"email":"...",
"department":"Computer",
"username":"...",
"password":"...",
"role":"HOD"
  }
  • ❗Don't forget to fill "..." with necessary details instead of leaving it as it is.

NOTE

Don't forget to comment out "|| !origin" Inside config/corsOptions.js after development.

 if (
      allowedOrigins.indexOf(origin) !== -1
      //! comment out/remove in production
      // || !origin
    )

Continue to Kollege Documentation

Still getting errors?

Go to config/corsOptions.js. Make sure your front-end address is included in allowedOptions:

const allowedOrigins = [
  "http://localhost:3000",
  // Add the address if you host your front-end somewhere
  "https://example.address.com",
];

Contact

Errors are bound to happen and the documentation is incomplete.
I'd love to hear feedbacks and suggestions.
In any case, start a conversation: LinkedIn Telegram Mail(Make sure your mail doesn't get flagged as spam/junk)
Thank You ❤️.

Acknowledgements

Related

Kollege

License

MIT