I'm in the process of constructing an express server
using typescript
and Bun
. Recently, I completed my register route:
import express from "express";
const router = express.Router();
router.get('/registerUser',(_req:express.Request,res:express.Response): void => {
res.send('Hello World');
});
module.exports = router;
index.ts
:
SERVER.use('/pmo/api/v1/auth', require('./controllers/auth_controllers/register.controller.ts'));
This is what my tsconfig file looks like:
"compilerOptions": {
"lib": ["ESNext"],
"module": "esnext",
"target": "esnext",
"moduleResolution": "bundler",
"moduleDetection": "force",
"allowImportingTsExtensions": true,
"noEmit": true,
"composite": true,
"strict": true,
"downlevelIteration": true,
"skipLibCheck": true,
"jsx": "react-jsx",
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"allowJs": true,
"types": [
"bun-types" // add Bun global
]
}
}
I searched for solutions online and browsed through forums but couldn't find anyone facing the same issue. Most suggestions involved adding type="module"
to the script tag, but since I don't have an HTML file, I've included it in my package.json
instead.