forked from CleverCloud/onboarder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
48 lines (44 loc) · 1.33 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const path = require('path')
const express = require('express')
const exphbs = require('express-handlebars')
const Client = require('node-rest-client').Client
const client = new Client()
const app = express()
const port = 8080
// The id of your deployed application is accessible
// as an envrionment variable
const appID = process.env['APP_ID']
app.engine('.hbs', exphbs({
defaultLayout: 'main',
extname: '.hbs',
layoutsDir: path.join(__dirname, 'views/layouts')
}))
app.set('view engine', '.hbs')
app.set('views', path.join(__dirname, 'views'))
app.get('/', (request, response) => {
// Hello, it's good to see you here.
// Change the name and email so we know who you are!
let args = {
data: {
"firstname":"Pierre-Louis",
"lastname":"Duhoux",
"email":"[email protected]",
"id":appID
},
headers: { "Content-Type": "application/json" }
};
// You are nearly there!
client.post("http://onboarder.cleverapps.io/play", args, function (data, response) {
console.log(response);
});
// If you want to dig further you should watch this: https://www.youtube.com/watch?v=CeaoTAXkIZE
response.render('home', {
appID: appID
})
})
app.listen(port, (err) => {
if (err) {
return console.log('something bad happened', err)
}
console.log(`server is listening on ${port}`)
})