mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Fix warnings in the API package
This commit is contained in:
parent
c9c817bfb4
commit
5f6f3ba3b2
5 changed files with 6 additions and 17 deletions
|
|
@ -17,16 +17,12 @@ import { promisify } from 'util'
|
|||
import { buildLogger } from './utils/logger'
|
||||
import { ApolloServer } from 'apollo-server-express'
|
||||
import { makeExecutableSchema } from '@graphql-tools/schema'
|
||||
import { applyMiddleware } from 'graphql-middleware'
|
||||
import * as cookie from 'cookie'
|
||||
import typeDefs from './schema'
|
||||
import { sanitizeDirectiveTransformer } from './directives'
|
||||
import { functionResolvers } from './resolvers/function_resolvers'
|
||||
import ScalarResolvers from './scalars'
|
||||
import * as Sentry from '@sentry/node'
|
||||
import type { Express } from 'express'
|
||||
import { createPubSubClient } from './datalayer/pubsub'
|
||||
import { corsConfig } from './utils/corsConfig'
|
||||
import { initModels } from './server'
|
||||
|
||||
const signToken = promisify(jwt.sign)
|
||||
|
|
@ -107,7 +103,7 @@ const contextFunc: ContextFunction<ExpressContext, ResolverContext> = async ({
|
|||
return ctx
|
||||
}
|
||||
|
||||
export function makeApolloServer(app: Express): ApolloServer {
|
||||
export function makeApolloServer(): ApolloServer {
|
||||
let schema = makeExecutableSchema({
|
||||
resolvers,
|
||||
typeDefs,
|
||||
|
|
|
|||
|
|
@ -492,7 +492,7 @@ export const getArticleResolver: ResolverFn<
|
|||
Record<string, unknown>,
|
||||
WithDataSourcesContext,
|
||||
QueryArticleArgs
|
||||
> = async (_obj, { username, slug }, { claims, models }) => {
|
||||
> = async (_obj, { slug }, { claims, models }) => {
|
||||
try {
|
||||
if (!claims?.uid) {
|
||||
return { errorCodes: [ArticleErrorCode.Unauthorized] }
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ export const logOutResolver: ResolverFn<
|
|||
unknown,
|
||||
WithDataSourcesContext,
|
||||
unknown
|
||||
> = (_, __, { claims, clearAuth }) => {
|
||||
> = (_, __, { clearAuth }) => {
|
||||
try {
|
||||
clearAuth()
|
||||
return { message: 'User successfully logged out' }
|
||||
|
|
|
|||
|
|
@ -3,17 +3,12 @@
|
|||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
|
||||
import express from 'express'
|
||||
import axios from 'axios'
|
||||
import {
|
||||
CreateArticleErrorCode,
|
||||
CreateArticleSavingRequestResult,
|
||||
} from './../generated/graphql'
|
||||
import { CreateArticleErrorCode } from './../generated/graphql'
|
||||
import { isSiteBlockedForParse } from './../utils/blocked'
|
||||
import cors from 'cors'
|
||||
import { env } from './../env'
|
||||
import { buildLogger } from './../utils/logger'
|
||||
import * as jwt from 'jsonwebtoken'
|
||||
import { promisify } from 'util'
|
||||
import { corsConfig } from '../utils/corsConfig'
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { createPageSaveRequest } from '../services/create_page_save_request'
|
||||
|
|
@ -21,16 +16,14 @@ import { initModels } from '../server'
|
|||
import { kx } from '../datalayer/knex_config'
|
||||
|
||||
const logger = buildLogger('app.dispatch')
|
||||
const signToken = promisify(jwt.sign)
|
||||
|
||||
export function articleRouter() {
|
||||
const router = express.Router()
|
||||
|
||||
router.options('/save', cors<express.Request>({ ...corsConfig, maxAge: 600 }))
|
||||
router.post('/save', cors<express.Request>(corsConfig), async (req, res) => {
|
||||
const { url, v } = req.body as {
|
||||
const { url } = req.body as {
|
||||
url?: string
|
||||
v?: string
|
||||
}
|
||||
|
||||
const token = req?.cookies?.auth || req?.headers?.authorization
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ export const createApp = (): {
|
|||
// The error handler must be before any other error middleware and after all routes
|
||||
app.use(Sentry.Handlers.errorHandler())
|
||||
|
||||
const apollo = makeApolloServer(app)
|
||||
const apollo = makeApolloServer()
|
||||
const httpServer = createServer(app)
|
||||
|
||||
return { app, apollo, httpServer }
|
||||
|
|
|
|||
Loading…
Reference in a new issue