Security News
The Dark Side of Open Source
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
faker-ts
Advanced tools
Readme
Mock data from TypeScript
import { tsMock, tsMockService } from 'faker-ts';
const files = ['foo.ts'];
// foo.ts
// export interface IFoo { a: string }
const mocker = tsMock(files);
mocker.generateMock('IFoo'); // { "a": "commodo voluptate pariatur" }
// or listening file change
const mocker = tsMockService(files); // see more Mock Server with Koa
yarn global add faker-ts
e.g.
echo "interface IFoo { title: string; }" > foo.ts
faker-ts foo.ts IFoo # Mock data
import Koa from 'koa';
import Router from 'koa-router';
import * as ts from 'typescript';
import { tsMockService } from 'faker-ts';
export function createServer(files: string[], jsonCompilerOptions?: ts.CompilerOptions, basePath?: string) {
const app = new Koa();
const router = new Router();
const mocker = tsMockService(files, jsonCompilerOptions, basePath);
app.use(async (ctx, next) => {
try {
await next();
} catch (error) {
ctx.body = { msg: error.message };
}
});
router.get('/mocks/:symbol', async (ctx) => {
ctx.body = mocker.generateMock(ctx.params.symbol);
});
router.get('/schemas/:symbol', async (ctx) => {
ctx.body = mocker.generateSchema(ctx.params.symbol);
});
router.get('/schemas', async (ctx) => {
ctx.body = mocker.generateSchema();
});
router.get('/symbols', async (ctx) => {
ctx.body = mocker.generator.getMainFileSymbols(mocker.program);
});
app
.use(router.routes())
.use(router.allowedMethods());
return app;
}
FAQs
Mock data from TypeScript
The npm package faker-ts receives a total of 21 weekly downloads. As such, faker-ts popularity was classified as not popular.
We found that faker-ts demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
At Node Congress, Socket CEO Feross Aboukhadijeh uncovers the darker aspects of open source, where applications that rely heavily on third-party dependencies can be exploited in supply chain attacks.
Research
Security News
The Socket Research team found this npm package includes code for collecting sensitive developer information, including your operating system username, Git username, and Git email.
Security News
OpenJS is warning of social engineering takeovers targeting open source projects after receiving a credible attempt on the foundation.