mirror of
https://github.com/kou029w/_.git
synced 2025-01-30 22:08:02 +00:00
create ts
This commit is contained in:
parent
57301eccd2
commit
304d2aa963
5 changed files with 1538 additions and 0 deletions
1
ts/.gitignore
vendored
Normal file
1
ts/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
dist/
|
33
ts/README.md
Normal file
33
ts/README.md
Normal 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
17
ts/main.ts
Normal 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
15
ts/package.json
Normal 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
1472
ts/pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue