-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
81 lines (77 loc) · 2.03 KB
/
app.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
'use strict'
const { createServer, proxy } = require('aws-serverless-express')
// const { DynamoDBClient, ScanCommand } = require('@aws-sdk/client-dynamodb')
// const { unmarshall } = require("@aws-sdk/util-dynamodb")
const express = require('express')
const { Nuxt } = require('nuxt-start')
const config = require('./nuxt.config.js')
// const dbclient = new DynamoDBClient({})
// const CACHE = {
// aboutCards: [],
// workCards: []
// }
const app = express()
const nuxt = new Nuxt({
...config,
dev: false,
_start: true
})
// app.use(async (req, res, next) => {
// try {
// if (CACHE.aboutCards.length === 0 || CACHE.workCards.length === 0) {
// const aboutParams = {
// TableName: 'AboutCardTable'
// }
// const aboutResults = await dbclient.send(new ScanCommand(aboutParams));
// CACHE.aboutCards = aboutResults.Items.map(card => unmarshall(card))
//
// const workParams = {
// TableName: 'WorkCardTable'
// }
// const workResults = await dbclient.send(new ScanCommand(workParams));
// CACHE.workCards = workResults.Items.map(card => unmarshall(card))
// }
// console.log(CACHE.aboutCards)
//
// res.locals.aboutCards = CACHE.aboutCards
// res.locals.workCards = CACHE.workCards
// next()
// } catch (err) {
// console.error(err)
// next()
// }
// })
app.use(async (req, res) => {
if (nuxt.ready) {
await nuxt.ready()
}
nuxt.render(req, res)
})
// eslint-disable-next-line no-void
const server = createServer(app, void 0, [
'application/javascript',
'application/json',
'application/manifest+json',
'application/octet-stream',
'application/xml',
'font/eot',
'font/opentype',
'font/otf',
'image/gif',
'image/jpeg',
'image/png',
'image/svg+xml',
'image/x-icon', // for favicon
'text/comma-separated-values',
'text/css',
'text/html',
'text/javascript',
'text/plain',
'text/text',
'text/xml',
'application/rss+xml',
'application/atom+xml'
])
module.exports.handler = (event, ctx) => {
proxy(server, event, ctx)
}