Skip to content
This repository has been archived by the owner on May 4, 2023. It is now read-only.
/ nerver Public archive

A node simple Server, create a ts(TypeScript) file, and respond your body, just like a static server or PHP.

Notifications You must be signed in to change notification settings

BoltDoggy/nerver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nerver

A node simple Server, create a ts(TypeScript) file, and respond your body, just like a static server or PHP.

# open a dir, just run nerver
npx nerver

# need node, npm(with npx)

Create or Edit ./xxx.ts:

export default (ctx) => {
    return {
        Hello: 'Nerver'
    }
}

visit http://127.0.0.1:3000/xxx, you will got {"Hello":"Nerver"};

  • QA - 常见问题
  • e.g. - 示例

ENV

port=3001 nerver

or

Create .env:

port=3001

Static Server

Any static file, but *.ts and .*.

/index.html => got `/index.html` or `/index.html.ts`
/any.json => got `any.json` or `any.json.ts`
/any.jpg => got `any.jpg` or `any.jpg.ts`
...
/any.ts => got `Not Found`
/.env => got `Not Found`

ctx

Just a koa context - https://koajs.com/#context

ctx.query
ctx.request.body
ctx.request.fields
ctx.request.files
ctx.cookies.get(key)
ctx.cookies.set(key, value)

About

A node simple Server, create a ts(TypeScript) file, and respond your body, just like a static server or PHP.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published