Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

create-bridge-app

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-bridge-app - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

dist/code.js

50

dist/index.js

@@ -10,2 +10,3 @@ #!/usr/bin/env node

const prettier_1 = __importDefault(require("prettier"));
const code_1 = require("./code");
// import minimist from 'minimist';

@@ -38,50 +39,3 @@ // const argv = minimist(process.argv.slice(2));

});
fs_1.default.writeFile(`${name}/index.ts`, prettier_1.default.format(`import { initBridge, handler, onError, StatusCode, httpError, apply } from 'bridge';
import express from 'express';
import z from 'zod';
const port = 8080;
const authMiddleware = handler({
headers: z.object({ token: z.string().min(5) }),
resolve: ({ headers }) => {
if (headers.token !== 'private_token') return httpError(StatusCode.UNAUTHORIZED, 'Wrong token');
else return { firstName: 'John', name: 'Doe', age: 21 };
},
});
const updateUser = handler({
middlewares: apply(authMiddleware),
body: z.object({ age: z.number() }),
resolve: ({ mid, body }) => {
const user = mid;
user.age = body.age;
return user;
},
});
const routes = {
hey: handler({ resolve: () => 'hey' }),
hello: handler({
query: z.object({ name: z.string().optional() }),
method: 'GET',
resolve: ({ query }) => \`Hello \${query.name}\`,
}),
user: {
update: updateUser,
},
};
const errorHandler = onError(({ error, path }) => {
if (error.name === 'Internal server error') console.log(path, error); // Send to bug reporting
else console.log(path, error.status, error.name);
});
const app = express();
app.use('', initBridge({ routes, errorHandler }).expressMiddleware());
app.listen(port, () => {
console.log(\`Listening on port \${port}\`);
});`, { parser: 'typescript' }), () => { });
fs_1.default.writeFile(`${name}/index.ts`, prettier_1.default.format(code_1.indexFile, { parser: 'typescript' }), () => { });
},

@@ -88,0 +42,0 @@ });

{
"name": "create-bridge-app",
"version": "1.0.6",
"version": "1.0.7",
"description": "Create Bridge-powered Express app with one command",

@@ -5,0 +5,0 @@ "author": "Bridge Team <support@bridge.codes>",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc