Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion api/.nvmrc

This file was deleted.

3 changes: 2 additions & 1 deletion api/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "state-of-js-graphql-results-api",
"name": "@stateofjs/api",
"version": "1.0.0",
"license": "MIT",
"dependencies": {
"@octokit/core": "^3.5.1",
"@sentry/node": "^6.13.3",
"@sentry/tracing": "^6.13.3",
"@stateofjs/common": "1.0.0",
"apollo-server-express": "^3.3.0",
"apollo-server-plugin-response-cache": "^3.2.0",
"dotenv": "^10.0.0",
Expand Down
39 changes: 20 additions & 19 deletions api/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,30 @@ import { clearCache } from './caching'
// import Tracing from '@sentry/tracing'

import path from 'path'
import { testCommon } from '@stateofjs/common'

testCommon()

const Sentry = require('@sentry/node')
const Tracing = require('@sentry/tracing')

const app = express()

const environment = process.env.ENVIRONMENT || process.env.NODE_ENV;
const environment = process.env.ENVIRONMENT || process.env.NODE_ENV

Sentry.init({
dsn: process.env.SENTRY_DSN,
dsn: process.env.SENTRY_DSN,
integrations: [
// enable HTTP calls tracing
new Sentry.Integrations.Http({ tracing: true }),
// enable Express.js middleware tracing
// new Tracing.Integrations.Express({ app }),
],
// We recommend adjusting this value in production, or using tracesSampler
// for finer control
tracesSampleRate: 1.0,
environment,
});
// enable HTTP calls tracing
new Sentry.Integrations.Http({ tracing: true })
// enable Express.js middleware tracing
// new Tracing.Integrations.Express({ app }),
],
// We recommend adjusting this value in production, or using tracesSampler
// for finer control
tracesSampleRate: 1.0,
environment
})

// const path = require('path')

Expand Down Expand Up @@ -74,21 +77,21 @@ const start = async () => {
})
})

app.use(Sentry.Handlers.requestHandler());
app.use(Sentry.Handlers.requestHandler())
// TracingHandler creates a trace for every incoming request
// app.use(Sentry.Handlers.tracingHandler());

await server.start()

server.applyMiddleware({ app })

app.get('/', function (req, res) {
res.sendFile(path.join(__dirname + '/public/welcome.html'))
})

app.get('/debug-sentry', function mainHandler(req, res) {
throw new Error('My first Sentry error!');
});
throw new Error('My first Sentry error!')
})

app.get('/analyze-twitter', async function (req, res) {
checkSecretKey(req)
Expand All @@ -102,7 +105,7 @@ const start = async () => {
res.status(200).send('Cache cleared')
})

app.use(Sentry.Handlers.errorHandler());
app.use(Sentry.Handlers.errorHandler())

const port = process.env.PORT || 4000

Expand All @@ -112,8 +115,6 @@ const start = async () => {
app.listen({ port: port }, () =>
console.log(`🚀 Server ready at http://localhost:${port}${server.graphqlPath}`)
)


}

start()
4 changes: 3 additions & 1 deletion api/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"extends": "../tsconfig.json",
"references": [{ "path": "../common" }],
"compilerOptions": {
"composite": true,
"target": "es2017",
"module": "commonjs",
"lib": ["es7", "es2019"],
"outDir": "dist",
"rootDir": "src",
"removeComments": true,
"strict": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"noImplicitAny": true
Expand Down
2 changes: 1 addition & 1 deletion api/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
{
test: /\.ts$/,
exclude: /node_modules/,
use: 'ts-loader'
use: { loader: 'ts-loader', options: {"projectReferences": true} }
}
]
},
Expand Down
Loading