set port, load env vars and code formatting
This commit is contained in:
parent
bbe844ac44
commit
35e2e9b75d
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
|||||||
node_modules
|
node_modules
|
||||||
|
.env
|
22
index.js
22
index.js
@ -2,31 +2,31 @@
|
|||||||
// where your node app starts
|
// where your node app starts
|
||||||
|
|
||||||
// init project
|
// init project
|
||||||
var express = require('express');
|
require("dotenv").config();
|
||||||
|
var express = require("express");
|
||||||
var app = express();
|
var app = express();
|
||||||
|
|
||||||
|
const PORT = process.env.PORT || 43135;
|
||||||
|
|
||||||
// enable CORS (https://en.wikipedia.org/wiki/Cross-origin_resource_sharing)
|
// enable CORS (https://en.wikipedia.org/wiki/Cross-origin_resource_sharing)
|
||||||
// so that your API is remotely testable by FCC
|
// so that your API is remotely testable by FCC
|
||||||
var cors = require('cors');
|
var cors = require("cors");
|
||||||
app.use(cors({optionsSuccessStatus: 200})); // some legacy browsers choke on 204
|
app.use(cors({ optionsSuccessStatus: 200 })); // some legacy browsers choke on 204
|
||||||
|
|
||||||
// http://expressjs.com/en/starter/static-files.html
|
// 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
|
// http://expressjs.com/en/starter/basic-routing.html
|
||||||
app.get("/", function (req, res) {
|
app.get("/", function (req, res) {
|
||||||
res.sendFile(__dirname + '/views/index.html');
|
res.sendFile(__dirname + "/views/index.html");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// your first API endpoint...
|
// your first API endpoint...
|
||||||
app.get("/api/hello", function (req, res) {
|
app.get("/api/hello", function (req, res) {
|
||||||
res.json({greeting: 'hello API'});
|
res.json({ greeting: "hello API" });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// listen for requests :)
|
// listen for requests :)
|
||||||
var listener = app.listen(process.env.PORT, function () {
|
var listener = app.listen(PORT, function () {
|
||||||
console.log('Your app is listening on port ' + listener.address().port);
|
console.log("Your app is listening on port " + listener.address().port);
|
||||||
});
|
});
|
||||||
|
2116
package-lock.json
generated
2116
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
17
package.json
17
package.json
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "fcc-api-projects-boilerplate",
|
"name": "@radii-fcc-backend/fcc-api-projects-boilerplate",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"description": "An FCC Backend Challenge",
|
"description": "An FCC Backend Challenge",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
@ -7,22 +7,23 @@
|
|||||||
"start": "node index.js"
|
"start": "node index.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"express": "^4.12.4",
|
"cors": "^2.8.0",
|
||||||
"cors": "^2.8.0"
|
"dotenv": "^16.0.3",
|
||||||
|
"express": "^4.12.4"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/freeCodeCamp/boilerplate-project-timestamp.git"
|
"url": "https://radii.dev/freeCodeCamp.org-Back-End-Dev-and-APIs/timestamp"
|
||||||
},
|
},
|
||||||
"bugs": {
|
"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",
|
"homepage": "https://radii.dev/freeCodeCamp.org-Back-End-Dev-and-APIs/timestamp#readme",
|
||||||
"author": "freeCodeCamp <team@freecodecamp.org>",
|
"author": "Radii <fcc@radii.dev>",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"node",
|
"node",
|
||||||
"express",
|
"express",
|
||||||
"freeCodeCamp"
|
"freeCodeCamp"
|
||||||
],
|
],
|
||||||
"license": "MIT"
|
"license": "AGPL-3.0-or-later"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user