Skip to content

Latest commit

 

History

History
74 lines (57 loc) · 1.88 KB

readme.md

File metadata and controls

74 lines (57 loc) · 1.88 KB

Documentation

* - TODO

Usage in Syncano Socket

To learn about Syncano Sockets visit documentation.

import Syncano from 'syncano-server'
          
export default async ctx => {
  // Initialize Syncano Server Library
  const {data, response} = new Syncano(ctx)

  // Check if user is authenticated
  if (!ctx.meta.user) {
    response.json({message: 'Unauthorized'}, 401)
    process.exit(0)
  }

  // Get user id from Socket Context
  const {id: author} = ctx.meta.user
  const {title} = ctx.args

  // Create post
  const post = await data.posts.create({title, author})

  // Respond with created post
  response.json(post)
}

Installation

To install Syncano Server Library, use npm or yarn in your socket.

npm i syncano-server --save