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
|
||||
.env
|
26
index.js
26
index.js
@ -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
|
||||
// so that your API is remotely testable by FCC
|
||||
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...
|
||||
// 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);
|
||||
});
|
||||
|
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",
|
||||
"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"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user