Files
linux-kernel-module-cheat/rootfs_overlay/lkmc/nodejs/express2.js
Ciro Santilli 六四事件 法轮功 13f7303db1 more node
2021-05-25 01:00:00 +00:00

30 lines
617 B
JavaScript
Executable File

#!/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)
})