
Security News
Rust RFC Proposes a Security Tab on crates.io for RustSec Advisories
Rustâs crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.
@typepoint/core
Advanced tools
Library for defining, serving and consuming strongly typed endpoints in TypeScript
Library for easily defining, enforcing, consuming, and/or serving strongly typed RESTful API endpoints in TypeScript.
npm install @typepoint/core --save
TypePoint requires at least TypeScript v2.8.
npm install typescript --save-dev
Let's say you need an endpoint which returns a Todo.
shared/models/todo.d.ts
interface Todo {
id: string;
title: string;
isCompleted: boolean;
}
First you define your endpoint in a shared place
shared/endpoints/todos/get.ts
import { Empty, EndpointDefinition } from '@typepoint/core/shared';
// Define this endpoint's request params, request body, and response body as well as the path
export const GetTodo = new EndpointDefinition<{ id: string }, Empty, Todo>(
path => path.literal('todos').param('id')
);
Now you've defined your endpoint, lets define a handler for it
server/handlers/todos/get.ts
import { defineHandler } from '@typepoint/core/server';
import { GetTodo } from '../shared/endpoints/todos/get.ts';
import { todoService } from './todoService';
export const GetTodoHandler = defineHandler(GetTodo, context => {
const id = context.request.params.id;
const todo = await todoService.get(id);
if (todo) {
context.response.body = todo;
} else {
context.response.statusCode = 404;
}
});
Now we just need to tie it all together by exporting our router as middleware that our express app can use.
server/app.ts
import * as express from 'express';
import { Router } from '@typepoint/core/server';
import { toMiddleware } from '@typepoint/core/server/express';
import { GetTodoHandler } from './handlers/todos/get.ts';
const app = express();
const router = new Router({
handlers: [
GetTodoHandler
]
});
// Convert router to middleware that express can use
app.use(toMiddleware(router));
const port = 3000;
app.listen(3000, () => {
console.log(`Listening on port ${ port }`);
})
Then on the client side you can call your endpoint like so
client/app.ts
import { TypePointClient } from '@typepoint/core/client';
import { GetTodo } from '../shared/endpoints/todos/get';
const client = new TypePointClient({
// location of your endpoints
server: 'https://www.example.com/api'
});
// The client will fetch https://www.example.com/api/todos/123
client.fetch(GetTodo, {
params: { // Params will be required and strongly typed
id: '123'
}
}).then(response => {
const todo = response.body; // body will be strongly typed to a Todo
alert(todo.title);
});
Currently TypePoint is pre v1.0.0, thus breaking changes may be introduced in minor versions instead of major versions. Patch versions will continue to just include bug fixes and other non breaking changes. Once TypePoint has reached 1.0.0 it will follow strict semantic versioning.
Got an problem or suggestion? Submit an issue!
Want to contribute? Fork the repository and submit a pull request! đ¸
FAQs
Library for defining, serving and consuming strongly typed endpoints in TypeScript
We found that @typepoint/core 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
Rustâs crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.

Security News
/Research
Socket found a Rust typosquat (finch-rust) that loads sha-rust to steal credentials, using impersonation and an unpinned dependency to auto-deliver updates.

Research
/Security Fundamentals
A pair of typosquatted Go packages posing as Googleâs UUID library quietly turn helper functions into encrypted exfiltration channels to a paste site, putting developer and CI data at risk.