forked from anmonteiro/now-static-bin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
31 lines (26 loc) · 983 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
const { createLambda } = require('@now/build-utils/lambda.js');
const glob = require('@now/build-utils/fs/glob.js');
const path = require('path');
const rename = require('@now/build-utils/fs/rename.js');
exports.config = {
maxLambdaSize: '25mb',
};
exports.build = async ({ files, entrypoint, config }) => {
// move all user code to 'user' subdirectory
const userFiles = rename(files, name => path.join('user', name));
const launcherFiles = await glob('**', path.join(__dirname, 'dist'));
const zipFiles = { ...userFiles, ...launcherFiles };
const { port, timeout } = Object.assign({}, config);
const lambda = await createLambda({
files: zipFiles,
handler: 'launcher',
runtime: 'go1.x',
environment: {
NOW_STATIC_BIN_LOCATION: path.join('user', entrypoint),
// TODO: default or error?
NOW_STATIC_BIN_PORT: '' + port || '8080',
NOW_STATIC_BIN_TIMEOUT: '' + timeout || '50',
},
});
return { [entrypoint]: lambda };
};