-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
35 lines (27 loc) · 734 Bytes
/
Copy pathapp.js
File metadata and controls
35 lines (27 loc) · 734 Bytes
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
const express = require('express')
const app = express()
var jwt = require('jsonwebtoken');
var fs = require('fs');
const PORT = 3000
app.use(express.static('public'))
app.get('/',(req,res) => {
res.sendFile('/index.html')
})
app.get('/services/jwt',(req,res) => {
const header = {
"alg": "ES256",
"typ": "JWT",
"kid": "yourmapjsidhere"
}
const payload = {
"iss": "yourteamidhere",
"iat": Date.now() / 1000,
"exp": (Date.now() / 1000) + 15778800,
}
var cert = fs.readFileSync('./private.p8'); // private key that you downloaded
var token = jwt.sign(payload,cert, { header: header } );
res.json({token: token})
})
app.listen(PORT,(req,res) => {
console.log("Server has started...")
})