open-apiify
v1.1.0-beta.23
Published
create web servers
Downloads
84
Readme
Open-apiify (WIP)
Quick run
mkdir my-app
cd my-app
bunx open-apiifyCommand line
apiify // quick create project and run dev
apiify init // create project
apiify build // build project
apiify start // run projectapiify start be should set env NODE_ENV=production
Route
Argument
str: string // param or query or body data (e.g. /foo?str=bar)
opsStr?: string // optional
arr: string[] // query or body array data
enumData: string // enum
date: Date // Date object
userAgent: Apiify.Header // user-agent header
req: Apiify.Req // http request
res: Apiify.Res // http response
file: Apiify.File // file upload
{ username, password }: Apiify.HTTPBasicAuth
cookies: Apiify.Cookies
formData: Apiify.FormStream // handle upload file without write to diskCreate argument
// src/args/random.ts
import { Apiify, createArgument } from "open-apiify";
export interface Random extends Number {}
export default createArgument<Random>("Random").implement((req, res, p) => {
return Math.random();
});
// src/route/num.ts
import { Random } from "../args/random.ts";
export default function (num: Random) {
return `number is ${num}`;
}Response
return "some text"; // response string
return { foo: "bar" }; // response json
return Apiify.File("../some_file.txt"); // response file
return "<b>some text</b>" as Apiify.html; // response html
return someStream; // response return streamThrow error
throw Apiify.Error("some error"); // or
return Apiify.Error("some error");
throw Apiify.Error(400, "error with code");Configuration
Use cat-config for configuration management.
See this.
test
Debug
Use the debug library
DEBUG=apiify