Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@freshsqueezed/mammothgql
Advanced tools
@freshsqueezed/mammothgql
express
Mammoth GQL enables the ability to run your GraphQL middleware as part of an app built with Express, one of the most popular web frameworks for Node.
First, install MammothGQL Middleware, the JavaScript implementation of the core GraphQL algorithms, Express, and two common Express middleware packages:
npm install @freshsqueezed/mammothgql graphql @graphql-tools/schema express cors
Then, write the following to ./src/app.ts
.
import express, { json } from 'express';
import cors, { CorsRequest } from 'cors';
import { mammothGraphql } from '@freshsqueezed/mammothgql';
import schema from './graphql';
import { ServerContext } from './types';
const schema = makeExecutableSchema({
typeDefs: `#graphql
type Query {
hello(s: String!): String
}
`,
resolvers: {
Query: {
hello: (_: never, { s }: { s: string }) => s,
},
},
});
const app = express();
app.use(cors<CorsRequest>());
app.use(json());
app.use(
'/graphql',
mammothGraphql<ServerContext>({
schema,
graphiql: true,
context: ({ req }) => ({
user: req.user || null,
}),
}),
);
export default app;
Create a ./src/index.ts
file and
import { createServer } from 'node:http';
import app from './app';
const httpServer = createServer(app);
httpServer.listen(3000, () => {
console.log(`
🚀 Server is running on http://localhost:${PORT}/graphql
`);
});
Now run your server with:
ts-node ./src/index.ts
Open the URL it prints in a web browser. It will show GraphiQL, a web-based tool for running GraphQL operations. Try running the operation query { hello(s: "world!") }
!
FAQs
GraphQL middleware for express framework
We found that @freshsqueezed/mammothgql demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.