1
0
Fork 0
mirror of https://github.com/kou029w/_.git synced 2025-01-30 22:08:02 +00:00

create ts

This commit is contained in:
Nebel 2023-06-19 15:20:17 +09:00
parent 57301eccd2
commit 304d2aa963
Signed by: nebel
GPG key ID: 79807D08C6EF6460
5 changed files with 1538 additions and 0 deletions

1
ts/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
dist/

33
ts/README.md Normal file
View file

@ -0,0 +1,33 @@
# TypeScript で書いたサーバーをワンライナーで構築してみよう
tsup
```
npx tsup main.ts --clean --onSuccess 'node dist/main.js'
```
tsup + watch
```
npx tsup main.ts --clean --watch --onSuccess 'node dist/main.js'
```
ts-node
```
npx ts-node-transpile-only main.ts
```
ts-node + watch
n/a
esbuild (esbuild-register)
```
node -r esbuild-register main.ts
```
esbuild (esbuild-register) + watch
n/a

17
ts/main.ts Normal file
View file

@ -0,0 +1,17 @@
import express from "express";
const app = express();
app.get("/", (req, res) => {
res.send("OK");
});
const address = app.listen(3000).address();
console.log(address);
(async () => {
const res = await fetch(`http://127.0.0.1:${address?.port}/`);
console.log(res.url, res.status, res.statusText);
console.log(await res.text());
})();

15
ts/package.json Normal file
View file

@ -0,0 +1,15 @@
{
"name": "ts",
"version": "1.0.0",
"private": true,
"devDependencies": {
"@types/express": "^4.17.17",
"@types/node": "^20.3.1",
"esbuild": "^0.18.4",
"esbuild-register": "^3.4.2",
"express": "^4.18.2",
"ts-node": "^10.9.1",
"tsup": "^7.0.0",
"typescript": "^5.1.3"
}
}

1472
ts/pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load diff