set port, load env vars and code formatting

This commit is contained in:
Manish 2023-03-28 01:43:08 +11:00
parent bbe844ac44
commit 35e2e9b75d
4 changed files with 1088 additions and 1072 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
node_modules
.env

View File

@ -2,31 +2,31 @@
// where your node app starts
// init project
var express = require('express');
require("dotenv").config();
var express = require("express");
var app = express();
const PORT = process.env.PORT || 43135;
// enable CORS (https://en.wikipedia.org/wiki/Cross-origin_resource_sharing)
// so that your API is remotely testable by FCC
var cors = require('cors');
app.use(cors({optionsSuccessStatus: 200})); // some legacy browsers choke on 204
var cors = require("cors");
app.use(cors({ optionsSuccessStatus: 200 })); // some legacy browsers choke on 204
// http://expressjs.com/en/starter/static-files.html
app.use(express.static('public'));
app.use(express.static("public"));
// http://expressjs.com/en/starter/basic-routing.html
app.get("/", function (req, res) {
res.sendFile(__dirname + '/views/index.html');
res.sendFile(__dirname + "/views/index.html");
});
// your first API endpoint...
app.get("/api/hello", function (req, res) {
res.json({greeting: 'hello API'});
res.json({ greeting: "hello API" });
});
// listen for requests :)
var listener = app.listen(process.env.PORT, function () {
console.log('Your app is listening on port ' + listener.address().port);
var listener = app.listen(PORT, function () {
console.log("Your app is listening on port " + listener.address().port);
});

20
package-lock.json generated
View File

@ -1,15 +1,16 @@
{
"name": "fcc-api-projects-boilerplate",
"name": "@radii-fcc-backend/fcc-api-projects-boilerplate",
"version": "0.0.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "fcc-api-projects-boilerplate",
"name": "@radii-fcc-backend/fcc-api-projects-boilerplate",
"version": "0.0.1",
"license": "MIT",
"license": "AGPL-3.0-or-later",
"dependencies": {
"cors": "^2.8.0",
"dotenv": "^16.0.3",
"express": "^4.12.4"
}
},
@ -142,6 +143,14 @@
"npm": "1.2.8000 || >= 1.4.16"
}
},
"node_modules/dotenv": {
"version": "16.0.3",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
"integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==",
"engines": {
"node": ">=12"
}
},
"node_modules/ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
@ -708,6 +717,11 @@
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
"integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg=="
},
"dotenv": {
"version": "16.0.3",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
"integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ=="
},
"ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",

View File

@ -1,5 +1,5 @@
{
"name": "fcc-api-projects-boilerplate",
"name": "@radii-fcc-backend/fcc-api-projects-boilerplate",
"version": "0.0.1",
"description": "An FCC Backend Challenge",
"main": "index.js",
@ -7,22 +7,23 @@
"start": "node index.js"
},
"dependencies": {
"express": "^4.12.4",
"cors": "^2.8.0"
"cors": "^2.8.0",
"dotenv": "^16.0.3",
"express": "^4.12.4"
},
"repository": {
"type": "git",
"url": "https://github.com/freeCodeCamp/boilerplate-project-timestamp.git"
"url": "https://radii.dev/freeCodeCamp.org-Back-End-Dev-and-APIs/timestamp"
},
"bugs": {
"url": "https://github.com/freeCodeCamp/freeCodeCamp/issues"
"url": "https://radii.dev/freeCodeCamp.org-Back-End-Dev-and-APIs/timestamp"
},
"homepage": "https://github.com/freeCodeCamp/boilerplate-project-timestamp#readme",
"author": "freeCodeCamp <team@freecodecamp.org>",
"homepage": "https://radii.dev/freeCodeCamp.org-Back-End-Dev-and-APIs/timestamp#readme",
"author": "Radii <fcc@radii.dev>",
"keywords": [
"node",
"express",
"freeCodeCamp"
],
"license": "MIT"
"license": "AGPL-3.0-or-later"
}