module.exports = Self => { Self.remoteMethodCtx('add', { description: 'Add a new operator', accessType: 'WRITE', http: { path: `/add`, verb: 'POST' } }); Self.add = async ctx => { const userId = ctx.req.accessToken.userId; const user = await Self.findById(userId); if (!user) { await Self.create({ workerFk: userId }); } }; };