-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
34 lines (27 loc) · 814 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const express = require('express');
const app = express();
const path = require('path');
const PORT = process.env.PORT || 3000;
require('dotenv').config();
const { format } = require('date-fns');
const { ptBR } = require('date-fns/locale');
app.use(express.json());
app.use(express.urlencoded({extended: true}));
app.use(express.static(path.join(__dirname, 'public')));
app.set('view engine', 'html');
app.get('/', (req, res) => {
res.render('index')
});
app.post('/key', (req, res) => {
res.json({
key: process.env.KEY
})
})
app.get('/date', (req, res) => {
let dateNow = Date.now();
let formatDate = format(dateNow, "EEEE, dd 'de' MMMM", {locale: ptBR});
res.json({
date: formatDate
})
})
app.listen(PORT, () => console.log(`Server is running in port ${PORT}`))