capy-wf
TypeScript icon, indicating that this package has built-in type declarations

1.1.8 • Public • Published

cwf

wakatime

The WIP web framework created to be used by j4ce.

Currently TypeScript only!

Setup Guide

  • Create an npm project.
  • Setup the folders more or less like this
📦The Main Folder
 ┣ 📂components
 ┃ ┗ 📜Xyz.cwf
 ┣ 📂src
 ┃ ┗ 📜index.ts
 ┣ 📂views
 ┃ ┣ 📂api
 ┃ ┃ ┗ 📜test.ts
 ┃ ┗ 📜index.cwf
 ┣ 📜package-lock.json
 ┗ 📜package.json
  • The index.ts file should look like this
import { cwf } from 'capy-wf';

const app = cwf({
  debug: true,
});

app.listen();
  • Install ts-node-dev
    npm i --save-dev ts-node-dev
  • Add a dev script to the package.json file
    "dev": "ts-node-dev ./src/index.ts"
  • Run it!
    npm run dev

Api Example

Put the file in views/api/{apiName}.ts

Should look like this:

import { ApiContext } from 'capy-wf';

export default async function (ctx: ApiContext) {
  console.log(`Got: ${ctx.method}`);

  ctx.sendJson({
    hello: 'world',
  });
}

Readme

Keywords

none

Package Sidebar

Install

npm i capy-wf

Weekly Downloads

1

Version

1.1.8

License

ISC

Unpacked Size

65.5 kB

Total Files

49

Last publish

Collaborators

  • rosen2419