Skip to content

Commit f52256c

Browse files
authored
Merge pull request #612 from AikidoSec/optional-types
Use @ts-ignore instead of @ts-expect-error
2 parents 62d750c + 217e91f commit f52256c

File tree

7 files changed

+1132
-3
lines changed

7 files changed

+1132
-3
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const t = require("tap");
2+
const { execSync } = require("child_process");
3+
const { resolve } = require("path");
4+
5+
const pathToApp = resolve(__dirname, "../../sample-apps/import-middleware-ts");
6+
7+
t.test("it passes type check when skipLibCheck is set to false", async (t) => {
8+
try {
9+
execSync(`npm run type-check`, {
10+
cwd: pathToApp,
11+
});
12+
} catch (error) {
13+
t.fail(error.stdout.toString());
14+
}
15+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# import-middleware-ts
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import Zen from "@aikidosec/firewall";
2+
import express from "express";
3+
import morgan from "morgan";
4+
5+
async function main(port: number) {
6+
const app = express();
7+
8+
app.use(morgan("tiny"));
9+
app.use(express.json());
10+
11+
Zen.addExpressMiddleware(app);
12+
13+
app.get("/", (_, res) => {
14+
res.send("Hello World!");
15+
});
16+
17+
return new Promise<void>((resolve, reject) => {
18+
try {
19+
app.listen(port, () => {
20+
console.log(`Listening on port ${port}`);
21+
resolve();
22+
});
23+
} catch (err) {
24+
reject(err);
25+
}
26+
});
27+
}
28+
29+
function getPort() {
30+
const port = parseInt(process.argv[2], 10) || 4000;
31+
32+
if (isNaN(port)) {
33+
console.error("Invalid port");
34+
process.exit(1);
35+
}
36+
37+
return port;
38+
}
39+
40+
main(getPort());

0 commit comments

Comments
 (0)