1.0.26 • Published 4 months ago

@remotezygote/koa-api-app v1.0.26

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months ago

Koa API App

Use this as the base for your API app. It's very simple:

import app, {
  exposed,
  body,
  paginate,
  filter,
  get,
  post,
  put,
  del,
  start,
} from "@remotezygote/koa-api-app"
import { ParameterizedContext } from "koa"

const getEnvironment = async (ctx: ParameterizedContext) => {}

const getCurrentUser = async (ctx: ParameterizedContext) => {
  const { user } = ctx.state

  ctx.body = user
  ctx.status = 200
}

exposed.get("/env", getEnvironment) // listen at /env with no authentication needed
get("/me", getCurrentUser) // listen at /me with authenication needed
put("/me", body(), updateUser) // update current user with authentication needed (also read the body)
put("/users", paginate(), getUsers) // get users with pagination (ctx.state.paginate)
put("/users", filter(), getUsers) // get users with filters (ctx.state.filters)
put("/me", body(), paginate(), filter(), getCertainUsers) // read the body, paginate, and parse filters
1.0.26

4 months ago

1.0.25

4 months ago

1.0.24

4 months ago

1.0.19

10 months ago

1.0.18

10 months ago

1.0.16

10 months ago

1.0.9

10 months ago

1.0.6

10 months ago

1.0.11

10 months ago

1.0.21

10 months ago

1.0.10

10 months ago

1.0.20

10 months ago

1.0.15

10 months ago

1.0.14

10 months ago

1.0.13

10 months ago

1.0.23

8 months ago

1.0.12

10 months ago

1.0.5

11 months ago

1.0.4

11 months ago