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

edgeql

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

edgeql - npm Package Compare versions

Comparing version 0.0.8 to 0.0.10

dist/middleware/jwt/index.d.ts

1

dist/app.d.ts

@@ -1,2 +0,1 @@

/// <reference types="@cloudflare/workers-types" />
import type { GraphQLFieldResolver, GraphQLSchema } from 'graphql';

@@ -3,0 +2,0 @@ import { Context } from './context';

@@ -1,2 +0,1 @@

/// <reference types="@cloudflare/workers-types" />
import type { GraphQLSchema } from 'graphql';

@@ -3,0 +2,0 @@ import { Req } from './request';

@@ -1,2 +0,1 @@

/// <reference types="@cloudflare/workers-types" />
import type { DocumentNode } from 'graphql';

@@ -3,0 +2,0 @@ export declare class Req {

@@ -1,5 +0,5 @@

/// <reference types="@cloudflare/workers-types" />
export declare class Res {
private _headers;
private _status;
private _statusText;
private _body;

@@ -10,2 +10,4 @@ toJSON(): Response;

get status(): number | undefined;
set statusText(text: string | undefined);
get statusText(): string | undefined;
get headers(): Headers;

@@ -12,0 +14,0 @@ set body(body: any);

@@ -6,4 +6,6 @@ export class Res {

toJSON() {
this.headers.set('content-type', 'application/json');
return new Response(JSON.stringify(this.body), {
status: this.status ?? 200,
statusText: this.statusText ?? '',
headers: this.headers,

@@ -24,2 +26,8 @@ });

}
set statusText(text) {
this._statusText = text;
}
get statusText() {
return this._statusText;
}
get headers() {

@@ -26,0 +34,0 @@ return this._headers;

{
"name": "edgeql",
"version": "0.0.8",
"version": "0.0.10",
"license": "MIT",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": ["dist/**/*"],
"files": [
"dist/**/*"
],
"scripts": {

@@ -27,2 +29,4 @@ "build": "tsc",

"@cloudflare/workers-types": "^4.20240117.0",
"@edge-runtime/vm": "^3.2.0",
"@pothos/core": "^3.41.0",
"@types/crypto-js": "^4.1.1",

@@ -35,2 +39,3 @@ "@types/glob": "^8.0.0",

"@vitest/coverage-v8": "^1.2.2",
"eslint": "^8.56.0",
"eslint-config-prettier": "^8.5.0",

@@ -43,9 +48,7 @@ "eslint-define-config": "^1.4.0",

"eslint-plugin-node": "^11.1.0",
"prettier": "^3.2.4",
"typescript": "^5.3.3",
"vite": "^5.0.12",
"vitest": "^1.2.2",
"wrangler": "3.25.0",
"@pothos/core": "^3.41.0",
"eslint": "^8.56.0",
"prettier": "^3.2.4"
"wrangler": "3.25.0"
},

@@ -52,0 +55,0 @@ "engines": {

# EdgeQL
Bringing GraphQL to the Edge with effortless lightness.
Effortlessly craft GraphQL APIs on the Edge.
## Quick Start
### Hello World
EdgeQL supports both Schema-First and Code-First.
* Schema First
```typescript

@@ -24,3 +25,3 @@ import { EdgeQL } from 'edgeql'

### Middleware
* Code First

@@ -51,37 +52,26 @@ ```typescript

})
```
const clock: GraphQLSchema = new GraphQLSchema({
query: new GraphQLObjectType({
name: 'Query',
fields: {
clock: {
type: GraphQLString,
resolve: (parent: any, args: any, ctx: Context, info: any) => {
return new Date().toISOString()
},
},
},
})
})
### Middlewares
// register schema
app.register({
schema: helloworld,
})
EdgeQL adopts the same middleware style like Koa, middleware are simple functions which return a `MiddlewareFunction` with signature (ctx, next). When the middleware is run, it must manually invoke `next()` to run the "downstream" middleware.
app.register({
schema: clock,
})
For example if you wanted to track how long it takes for a request to propagate through Koa by adding an `X-Response-Time` header field the middleware would look like the following:
// middleware
app.use(async (ctx: Context, next: Next) => {
const startedAt = new Date()
await next()
const endedAt = new Date()
ctx.res.headers.set('x-response-time', `${endedAt.getTime() - startedAt.getTime()}`)
})
```typescript
async function responseTime(ctx: Context, next: Next) {
const start = Date.now();
await next();
const ms = Date.now() - start;
ctx.set('X-Response-Time', `${ms}ms`);
}
export default app
app.use(responseTime);
```
The builtin middlewares are,
* [JWT](src/middleware/jwt)
* [wallclock](src/middleware/wallclock)
### examples

@@ -88,0 +78,0 @@

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