Merge pull request #107 from omnivore-app/fix/api-warnings

Fix warnings in the API package
This commit is contained in:
Jackson Harper 2022-02-23 01:25:47 +08:00 committed by GitHub
commit d8e71386f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 17 deletions

View file

@ -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,

View file

@ -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] }

View file

@ -220,7 +220,7 @@ export const logOutResolver: ResolverFn<
unknown,
WithDataSourcesContext,
unknown
> = (_, __, { claims, clearAuth }) => {
> = (_, __, { clearAuth }) => {
try {
clearAuth()
return { message: 'User successfully logged out' }

View file

@ -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

View file

@ -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 }