lau1944/bunrest

dies on start + typescript errors

selfagency opened this issue · 1 comments

when i try using bunrest following the directions in the readme, the app seems to just skip over bunrest and terminates:

my code:

import server from 'bunrest'

const app = server()
const router = app.router()

router.get('/test', (req, res) => {
  res.status(200).json({ message: 'Router succeed' })
})

app.use((req, res, next, err) => {
  res.status(500).send('Error happened')
})

console.log('hello!')

the result:

» bun run src/index.ts
hello!

i tried compiling the typescript to see if that would work and this happened:

12:51:58 AM » tsc src/**/*.ts
node_modules/bunrest/src/router/router.ts:10:8 - error TS1259: Module '"path"' can only be default-imported using the 'esModuleInterop' flag

10 import path from "path";
          ~~~~

  node_modules/@types/node/path.d.ts:178:5
    178     export = path;
            ~~~~~~~~~~~~~~
    This module is declared with 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.

node_modules/bunrest/src/server/response.ts:21:34 - error TS2339: Property 'json' does not exist on type '{ new (body?: BodyInit, init?: ResponseInit): Response; prototype: Response; error(): Response; redirect(url: string | URL, status?: number): Response; }'.

21         this.response = Response.json(body, this.options);
                                    ~~~~

node_modules/bunrest/src/server/server.ts:33:14 - error TS1056: Accessors are only available when targeting ECMAScript 5 and higher.

33   static get instance() {
                ~~~~~~~~

node_modules/bunrest/src/server/server.ts:118:12 - error TS2304: Cannot find name 'Bun'.

118     return Bun.serve({
               ~~~


Found 4 errors in 3 files.

Errors  Files
     1  node_modules/bunrest/src/router/router.ts:10
     1  node_modules/bunrest/src/server/response.ts:21
     2  node_modules/bunrest/src/server/server.ts:33

never mind, i'm an idiot who missed this part

app.listen(3000, () => {
  console.log('App is listening on port 3000');
});