Custom wrapper for syncano-core library


2131.0.02 years ago4 years agoMinified + gzip package size for @eyedea/syncano in KB



Custom wrapper for @syncano/core library.

npm version license


$ npm install --save @eyedea/syncano


import * as S from '@eyedea/syncano'

// Define arguments that endpoint will receive
interface Args {
  id: string

class Endpoint extends S.Endpoint<Args> {
  async run(
    {data, response /* users, endpoint etc. */}: S.Core, // Access to syncano
    {args, meta, config}: S.Context<Args> // Access to args, meta and config
  ) {
    if (!this.user) {
      // Errors thrown using S.HttpError are returned as response. In this case:
      // {message: 'Unauthorized!'} with status code 401
      throw new S.HttpError('Unauthorized!', 401)

    // You can directly return syncano query ...
    return data.post.find(10)

    // ... or use response method
    response.json({posts}, 200)

  // Any error thrown in `run` method can be handled using `endpointDidCatch` method
  endpointDidCatch({message}: Error) {
    this.syncano.response.json({message}, 400)

export default ctx => new Endpoint(ctx)


View @eyedea/syncano-test


MIT © Eyedea AS

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.