Skip to content

$ npm i zely@next
$ npm i zely@next

We are preparing v1.0! This post will explain the changes.

Alternative to res.end

Now you don't have to use res.end anymore!
res.end, res.send, res.json... There are times when I wonder what to use. When you have such trouble, just use return.

ts
export function get() {
  return { foo: 'bar' };
}
export function get() {
  return { foo: 'bar' };
}

No more... functions!

You can also make { foo: "bar" } simpler.

ts
export default {
  // default: "all"
  foo: 'bar',
};
export default {
  // default: "all"
  foo: 'bar',
};
ts
export function all() {
  return { foo: 'bar' };
}
export function all() {
  return { foo: 'bar' };
}

INFO

This feature will become default routing in the future.

If I use this, can I not access the req and res?

No, you can access the req and res. See examples.

ts
export default [
  (req, res) => {
    res.json({ foo: 'bar' }); // or... return { foo: 'bar' }
  },
];
export default [
  (req, res) => {
    res.json({ foo: 'bar' }); // or... return { foo: 'bar' }
  },
];

I want to receive requests only when req.method is post.

ts
import { POST } from 'zely/methods';

export default [POST({ foo: 'bar' })];
import { POST } from 'zely/methods';

export default [POST({ foo: 'bar' })];

WARNING

serverDataHandler is an experimental feature.

Etc

useBrackets

useBrackets is no longer an experimental feature.