Skip to content

Instantly share code, notes, and snippets.

@bessa3301
Created October 3, 2020 22:27
Show Gist options
  • Select an option

  • Save bessa3301/3f84899a3dd7f645ef84f0f0fe942498 to your computer and use it in GitHub Desktop.

Select an option

Save bessa3301/3f84899a3dd7f645ef84f0f0fe942498 to your computer and use it in GitHub Desktop.
TEAM BAZINGA NASA SAC 2020
'use strict'
const fastify = require('fastify')({ logger: false, trustProxy: true })
const redis = require('redis').createClient({ host: 'localhost', port: 6379 })
const path = require('path')
const helmet = require('fastify-helmet')
require('dotenv').config()
fastify
.register(require('fastify-static'), {
root: path.join(__dirname, 'public'),
prefix: '/public/',
}).register(helmet, { contentSecurityPolicy: false })
fastify.get('/', async (request, reply) => {
let { ip } = request
let strTemplate = `New visitor ${ip}`
redis.lpush("visitors", strTemplate)
reply.sendFile('TeamBazinga.html')
})
// js and css files
fastify.get('/css/home', async function (request, reply) {
reply.sendFile('bazinga.css')
})
// reveal Js -> https://revealjs.com/
fastify.get('/js/reveal', async function (request, reply) {
reply.sendFile('/dist/reveal.js')
})
fastify.get('/css/revealReset', async function (request, reply) {
reply.sendFile('/dist/reset.css')
})
fastify.get('/css/reveal', async function (request, reply) {
reply.sendFile('/dist/reveal.css')
})
fastify.get('/css/revealMoon', async function (request, reply) {
reply.sendFile('/dist/theme/moon.css')
})
const start = async () => {
const { PORT } = process.env
try {
await fastify.listen(PORT)
console.log(`server listening on ${fastify.server.address().port}`)
} catch (err) {
fastify.log.error(err)
process.exit(1)
}
}
start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment