Skip to content

Commit

Permalink
added examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Code-Crash committed Sep 1, 2023
1 parent 69fc3a7 commit f80d689
Show file tree
Hide file tree
Showing 8 changed files with 1,080 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -285,4 +285,4 @@ log/
logs
*.log%
*.log
example*
lib
1 change: 1 addition & 0 deletions example/node/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
1 change: 1 addition & 0 deletions example/node/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18.16.1
38 changes: 38 additions & 0 deletions example/node/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const logger = require('code-logger');
const express = require('express');

const app = express();

const PORT = process.env.PORT || 5000;

app.get('/', (req, res) => {
console.log('do-console....');
console.log(logger.helpers.isApiEnabled());
res.json({ message: 'test' });
});

app.get('/do-start', (req, res) => {
console.log('do-start....');
logger.doStart();
logger.helpers.setApi('https://test.in.sg');
res.json({ message: 'test' });
});

app.get('/do-stop', (req, res) => {
console.log('do-stop....');
logger.doStop();
res.json({ message: 'test' });
});

app.listen(PORT, () => {
console.log(`server is running on port: ${PORT}`)
});

const gFetch = global.fetch;

global.fetch = async (...args) => {
// console.log('arguments: ', args);
return gFetch.apply(this, args);
}

fetch('http://google.com').then(data => { console.log('data.ok: ', data.ok) }).catch((error) => { console.log('error:', error) });
Loading

0 comments on commit f80d689

Please sign in to comment.