-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* removed tslint * add eslint * add default config * setup default config and npm run command * add command to node.js.yml * set rules to support current codebase * remove unused tslint.json * include sample files in eslint command * remove rule no-explicit-any * specify type for timer * remove any from filterKeys * explictly declare that error can be Error, String but still accept any from the end users * specify types in the sync worker * improve the IndexableError type * explain why any is allowed in CustomData * remove no-this-alias from eslint config * convert to arrow function to preserve this reference * use arrow functions to remove the need of a this alias * define httpoptions object instead of using this alias * add examples to prettier command * add prettier job to node js ci job * script fix * setup no-unused-vars lint rule * remove unused var * fixed lib/raygun.batch.ts * fix lib/raygun.offline.ts * cleanup lib/raygun.sync.transport.ts * fix lib/raygun.transport.ts * fix lib/raygun.ts * fix @typescript-eslint/no-unused-vars * fixs in test files * update package lock in sample * cleanup eslint config * config files * run npm run prettier * Update .github/workflows/node.js.yml Co-authored-by: Sumitra Manga <[email protected]> * fix workflow * add comments to the package.json * add missing files * remove fetch-depth: 0 --------- Co-authored-by: Sumitra Manga <[email protected]>
- Loading branch information
1 parent
b790fbf
commit 3def9b9
Showing
22 changed files
with
191 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,3 +29,27 @@ jobs: | |
- run: npm ci | ||
- run: npm test | ||
- run: npm run eslint | ||
|
||
# Checks code formatting, fails if there are changes after applying prettier. | ||
# Based on this example here: | ||
# https://github.com/creyD/prettier_action?tab=readme-ov-file#example-4-dry-run | ||
prettier: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
# Make sure the actual branch is checked out when running on pull requests | ||
ref: ${{ github.head_ref }} | ||
# Make sure the value of GITHUB_TOKEN will not be persisted in repo's config | ||
persist-credentials: false | ||
|
||
- name: Prettify code | ||
uses: creyD/[email protected] | ||
with: | ||
# "dry" causes that if any file is modified, the job fails | ||
dry: True | ||
# "write" performs changes in place | ||
prettier_options: --write lib/*.ts test/*.js examples/**/*.js | ||
github_token: ${{ secrets.PERSONAL_GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,60 @@ | ||
var config = require('config'); | ||
var config = require("config"); | ||
|
||
if (config.Raygun.Key === 'YOUR_API_KEY') { | ||
console.error('You need to set your Raygun API key in the config file'); | ||
process.exit(1); | ||
if (config.Raygun.Key === "YOUR_API_KEY") { | ||
console.error("You need to set your Raygun API key in the config file"); | ||
process.exit(1); | ||
} | ||
|
||
// Setup Raygun | ||
var raygun = require('raygun'); | ||
var raygun = require("raygun"); | ||
var raygunClient = new raygun.Client().init({ | ||
apiKey: config.Raygun.Key | ||
apiKey: config.Raygun.Key, | ||
}); | ||
|
||
var express = require('express'); | ||
var path = require('path'); | ||
var logger = require('morgan'); | ||
var cookieParser = require('cookie-parser'); | ||
var bodyParser = require('body-parser'); | ||
var sassMiddleware = require('node-sass-middleware'); | ||
var express = require("express"); | ||
var path = require("path"); | ||
var logger = require("morgan"); | ||
var cookieParser = require("cookie-parser"); | ||
var bodyParser = require("body-parser"); | ||
var sassMiddleware = require("node-sass-middleware"); | ||
|
||
var routes = require('./routes/index'); | ||
var users = require('./routes/users'); | ||
var routes = require("./routes/index"); | ||
var users = require("./routes/users"); | ||
|
||
var app = express(); | ||
|
||
// Set the user if we have one | ||
raygunClient.user = function(req) { | ||
return '[email protected]'; | ||
raygunClient.user = function (req) { | ||
return "[email protected]"; | ||
}; | ||
|
||
// view engine setup | ||
app.set('views', path.join(__dirname, 'views')); | ||
app.set('view engine', 'ejs'); | ||
app.set("views", path.join(__dirname, "views")); | ||
app.set("view engine", "ejs"); | ||
|
||
// uncomment after placing your favicon in /public | ||
//app.use(favicon(__dirname + '/public/favicon.ico')); | ||
app.use(logger('dev')); | ||
app.use(logger("dev")); | ||
app.use(bodyParser.json()); | ||
app.use(bodyParser.urlencoded({ | ||
extended: false | ||
})); | ||
app.use( | ||
bodyParser.urlencoded({ | ||
extended: false, | ||
}), | ||
); | ||
app.use(cookieParser()); | ||
app.use(sassMiddleware({ | ||
src: __dirname, | ||
dest: path.join(__dirname, 'public'), | ||
debug: true, | ||
outputStyle: 'compressed', | ||
prefix: '/stylesheets' | ||
})); | ||
app.use(express.static(path.join(__dirname, 'public'))); | ||
|
||
app.use('/', routes); | ||
app.use('/users', users); | ||
app.use( | ||
sassMiddleware({ | ||
src: __dirname, | ||
dest: path.join(__dirname, "public"), | ||
debug: true, | ||
outputStyle: "compressed", | ||
prefix: "/stylesheets", | ||
}), | ||
); | ||
app.use(express.static(path.join(__dirname, "public"))); | ||
|
||
app.use("/", routes); | ||
app.use("/users", users); | ||
|
||
// Add the Raygun Express handler | ||
app.use(raygunClient.expressHandler); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
var express = require('express'); | ||
var express = require("express"); | ||
var router = express.Router(); | ||
|
||
/* GET home page. */ | ||
router.get('/', function(req, res, next) { | ||
res.render('index', { | ||
title: 'Express' | ||
}); | ||
router.get("/", function (req, res, next) { | ||
res.render("index", { | ||
title: "Express", | ||
}); | ||
}); | ||
|
||
router.get('/error', function(req, res, next) { | ||
// Call an object that doesn't exist to send an error to Raygun | ||
fakeObject.FakeMethod(); | ||
res.send(500); | ||
router.get("/error", function (req, res, next) { | ||
// Call an object that doesn't exist to send an error to Raygun | ||
fakeObject.FakeMethod(); | ||
res.send(500); | ||
}); | ||
|
||
module.exports = router; | ||
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
var express = require('express'); | ||
var express = require("express"); | ||
var router = express.Router(); | ||
|
||
/* GET users listing. */ | ||
router.get('/', function(req, res, next) { | ||
res.send('respond with a resource'); | ||
router.get("/", function (req, res, next) { | ||
res.send("respond with a resource"); | ||
}); | ||
|
||
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,52 @@ | ||
var config = require('config'); | ||
var config = require("config"); | ||
|
||
if (config.Raygun.Key === 'YOUR_API_KEY') { | ||
console.error('You need to set your Raygun API key in the config file'); | ||
process.exit(1); | ||
if (config.Raygun.Key === "YOUR_API_KEY") { | ||
console.error("You need to set your Raygun API key in the config file"); | ||
process.exit(1); | ||
} | ||
|
||
// Setup Raygun | ||
var raygun = require('raygun'); | ||
var raygunClient = new raygun.Client().init({apiKey: config.Raygun.Key}); | ||
var raygun = require("raygun"); | ||
var raygunClient = new raygun.Client().init({ apiKey: config.Raygun.Key }); | ||
|
||
// Create a domain | ||
var appDomain = require('domain').create(); | ||
var appDomain = require("domain").create(); | ||
|
||
// Add the error handler so we can pass errors to Raygun when the domain | ||
// crashes | ||
appDomain.on('error', function (err) { | ||
try { | ||
console.log(`Domain error caught: ${err}`); | ||
// Try send data to Raygun | ||
raygunClient.send(err, {}, function () { | ||
// Exit the process once the error has been sent | ||
console.log('Error sent to Raygun, exiting process'); | ||
process.exit(1); | ||
}); | ||
} catch (e) { | ||
// If there was an error sending to Raygun, log it out and end the process. | ||
// Could possibly log out to a text file here | ||
console.log(e); | ||
process.exit(1); | ||
} | ||
appDomain.on("error", function (err) { | ||
try { | ||
console.log(`Domain error caught: ${err}`); | ||
// Try send data to Raygun | ||
raygunClient.send(err, {}, function () { | ||
// Exit the process once the error has been sent | ||
console.log("Error sent to Raygun, exiting process"); | ||
process.exit(1); | ||
}); | ||
} catch (e) { | ||
// If there was an error sending to Raygun, log it out and end the process. | ||
// Could possibly log out to a text file here | ||
console.log(e); | ||
process.exit(1); | ||
} | ||
}); | ||
|
||
// Run the domain | ||
appDomain.run(function () { | ||
var fs = require('fs'); | ||
var fs = require("fs"); | ||
|
||
console.log('Running example app'); | ||
console.log("Running example app"); | ||
|
||
// Try and read a file that doesn't exist | ||
fs.readFile('badfile.json', 'utf8', function (err, file) { | ||
if (err) { | ||
// We could send the error straight to Raygun | ||
// raygunClient.send(err); | ||
// Try and read a file that doesn't exist | ||
fs.readFile("badfile.json", "utf8", function (err, file) { | ||
if (err) { | ||
// We could send the error straight to Raygun | ||
// raygunClient.send(err); | ||
|
||
// Or we can deal with it in our "Fake Error Handler" below | ||
// Or we can deal with it in our "Fake Error Handler" below | ||
|
||
// This will throw an error as fakeErrorHandler doesn't exist | ||
fakeErrorHandler.DealWith(err); | ||
} | ||
}) | ||
}); | ||
// This will throw an error as fakeErrorHandler doesn't exist | ||
fakeErrorHandler.DealWith(err); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.