🛋🚨 Checkpoint

./package.json:617503/2479
./server.js:617503/2250
This commit is contained in:
Glitch (hello-express) committed 2020-10-23 19:11:21 +00:00
1 parent a9554b78df
commit 1231e6f4ac
3 files changed
+381 -35

No files matched your search

+13 -29
View File
@@ -1,34 +1,18 @@
// server.js
// where your node app starts
// we've started you off with Express (https://expressjs.com/)
// but feel free to use whatever libraries or frameworks you'd like through `package.json`.
const express = require("express");
const app = express();
// our default array of dreams
const dreams = [
"Find and count some sheep",
"Climb a really tall mountain",
"Wash the dishes"
];
// make all the files in 'public' available
// https://expressjs.com/en/starter/static-files.html
app.use(express.static("public"));
// https://expressjs.com/en/starter/basic-routing.html
app.get("/", (request, response) => {
response.sendFile(__dirname + "/views/index.html");
// Require the framework and instantiate it
const fastify = require("fastify")({
logger: true
});
// send the default array of dreams to the webpage
app.get("/dreams", (request, response) => {
// express helps us take JS objects and send them as JSON
response.json(dreams);
// Declare a route
fastify.get("/", function(request, reply) {
reply.send({ hello: "world" });
});
// listen for requests :)
const listener = app.listen(process.env.PORT, () => {
console.log("Your app is listening on port " + listener.address().port);
// Run the server!
fastify.listen(process.env.PORT, function(err, address) {
if (err) {
fastify.log.error(err);
process.exit(1);
}
fastify.log.info(`server listening on ${address}`);
});