The Noroff Assignment API will be used to complete each of the assignments using JavaScript Frameworks.
In order to use the API you will require the following:
- Install Git
- Install NodeJS LTS with npm (It must be the LTS version.)
- Create a Railway account (free 500 hours p/m)
Follow the below instructions to get your API setup and ready for use.
- Fork this repository and clone the forked repository to your computer
- Run
npm install
in the root of the cloned repository - Ensure you have the Railway CLI Installed by running
npm i -g @railway/cli
in your terminal app (Windows users) - Check that Railway is installed by running
railway --version
- Run the following commands (In the project root directory):
- Initialize the project as a new Railway project
railway init
- Push the project Railway's cloud
railway up
- NOTE: You may be prompted to login; run
railway login
orrailway login --browserless
- Initialize the project as a new Railway project
- The app will be automatically deployed and started.
- Check the terminal and / or your Railway dashboard to see your deployed API.
Next, on your Railway dashboard, open your API application, find the Variables
tab and add the two required environmental variables. After adding your environmental variables, Railway will automatically redploy your application.
NODE_ENV : production
API_KEY : any randomly generated string (64 characters)
See the screenshot below.
Finally, click on the Settings
tab. In the Environment
section, click on the ⚡Generate Domain
button. A domain will be generated for your application, and the service will once again restart.
It will take a minute or two for the app to build and deploy, and then you will be able to access your API using the URL that has just been generated.
Each API endpoint contains both open and protected endpoints. All GET
endpoints are open. Any other method POST
, PUT
, PATCH
and DELETE
is protected with the X-API-KEY
header.