mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-25 19:21:35 +01:00
more node
This commit is contained in:
29
rootfs_overlay/lkmc/nodejs/express2.js
Executable file
29
rootfs_overlay/lkmc/nodejs/express2.js
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const assert = require('assert')
|
||||
const http = require('http')
|
||||
|
||||
const express = require('express')
|
||||
const app = express()
|
||||
const port = 3000
|
||||
|
||||
app.get('/error', async (req, res) => {
|
||||
throw 'my error'
|
||||
})
|
||||
|
||||
const server = app.listen(port, () => {
|
||||
// Test it.
|
||||
function test(path, method, status, body) {
|
||||
const options = {
|
||||
hostname: 'localhost',
|
||||
port: server.address().port,
|
||||
path: path,
|
||||
method: method,
|
||||
}
|
||||
http.request(options, res => {
|
||||
console.error(res.statusCode);
|
||||
assert(res.statusCode === status);
|
||||
}).end()
|
||||
}
|
||||
test('/error', 'GET', 500)
|
||||
})
|
||||
Reference in New Issue
Block a user