Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Declarative API definition for REST and real time APIs.
An API is defined by a JSON object:
declapi = require('../index.js')
t = declapi.types
api = {}
api.todo = {
actions:
listTasks:
rest:
type: "GET"
url: "/api/tasks"
description: "Lists all tasks"
params: {}
result:
tasks:
type: t.array
getTask:
description: "Get a task by id"
rest:
type: "GET"
url: "/api/tasks/:taskId"
params:
taskId:
type: t.string
result:
task:
type: t.object
addTask:
description: "Adds a task"
rest:
type: "POST"
url: "/api/tasks"
params:
taskId:
type: t.string
task:
type: t.object
properties:
description:
type: t.string
done:
type: t.boolean
optional: yes
result:
task:
type: t.object
properties:
description:
type: t.string
done:
type: t.boolean
}
Your Controller must implement the declared functions:
TodoApp = {
tasks: []
listTasks: -> @tasks
getTask: (taskId) ->
for t in @tasks
if t.id is taskId
return task
return null
addTask: (taskId, task) ->
unless task.done then task.done = no
task.id = taskId
@tasks.push task
return task
}
app = # Your express app
declapi = env.require 'decl-api'
todoApp = new TodoApp()
declapi.createExpressRestApi(app, api.todo, todoApp)
Returns the task list as JSON object
GET /api/tasks
RESPONSE {success: true, tasks: [...]}
Creates a task with the id: someId and returns it as JSON object
POST /api/tasks/someId
task[description]="some description"
task[done]=false
RESPONSE
{success: true, task: {id: "someId", description: "some description", done: false}}
Returns the task with id == someId
GET /api/tasks/someId
RESPONSE
{success: true, task: {id: "someId", description: "some description", done: false}}
FAQs
declarative API definition for REST and real time APIs
We found that decl-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.