mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-16 21:56:25 -05:00
0481b9a329
* chore: update react 18 * Create four-ways-try.md * Update signin.cy.ts * chore: new ci * Update e2e-ui.yml * Update e2e-ui.yml * ci * ci * ci * Update e2e-ui.yml * Update e2e-ui.yml * chore: fix ui test * Update publish.cy.ts * chore: update tests * add strict mode
27 lines
689 B
TypeScript
27 lines
689 B
TypeScript
import { rest } from 'msw';
|
|
|
|
const packagesPayload = require('./api/packages.json');
|
|
|
|
export const handlers = [
|
|
rest.get('http://localhost:9000/-/verdaccio/data/packages', (req, res, ctx) => {
|
|
return res(ctx.json(packagesPayload));
|
|
}),
|
|
|
|
rest.post<{ username: string; password: string }, { token: string; username: string }>(
|
|
'http://localhost:9000/-/verdaccio/sec/login',
|
|
// @ts-ignore
|
|
async (req, res, ctx) => {
|
|
const body = await req.json();
|
|
if (body.username === 'fail') {
|
|
return ctx.status(401);
|
|
}
|
|
|
|
return res(
|
|
ctx.json({
|
|
username: body.username,
|
|
token: 'valid token',
|
|
})
|
|
);
|
|
}
|
|
),
|
|
];
|