-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathdeploy.js
55 lines (53 loc) · 1.35 KB
/
deploy.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
const { TwilioServerlessApiClient } = require('../dist');
async function run() {
const config = {
username: process.env.TWILIO_ACCOUNT_SID,
password: process.env.TWILIO_AUTH_TOKEN,
};
const client = new TwilioServerlessApiClient(config);
console.log('Deploying');
const result = await client.deployProject({
...config,
overrideExistingService: true,
runtime: 'node22',
env: {
HELLO: 'ahoy',
WORLD: 'welt',
},
pkgJson: {
dependencies: {
'common-tags': '*',
'date-fns': '*',
},
},
serviceName: 'api-demo',
functionsEnv: 'test',
functions: [
{
name: 'hello-world',
path: '/hello-world',
content: `
const { stripIndent } = require('common-tags');
const { format } = require('date-fns');
exports.handler = function(context, event, callback) {
callback(null, stripIndent\`
\${context.HELLO} \${context.WORLD} \${format(new Date(2010, 4, 10), 'yyyy-MM-dd')}
\`);
};
`,
access: 'public',
},
],
assets: [
{
name: 'my-lib.js',
path: '/my-lib.js',
access: 'public',
content: 'exports.sum = (a, b) => a+b',
},
],
});
console.log('Done Deploying');
console.dir(result);
}
run().catch(console.error);