This file contains hidden or 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
| public static IHostBuilder CreateHostBuilder(string[] args) => | |
| Host.CreateDefaultBuilder(args) | |
| .ConfigureLogging(loggerBuilder => | |
| { | |
| loggerBuilder | |
| .ClearProviders() | |
| // Example output: [20/11/20 14:31:30:409] info: ... | |
| .AddConsole(configure => configure.TimestampFormat = "[dd/MM/yy HH:mm:ss:fff] "); | |
| }) |
This file contains hidden or 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
| public static IHostBuilder CreateHostBuilder(string[] args) => | |
| Host.CreateDefaultBuilder(args) | |
| .ConfigureWebHostDefaults(webBuilder => | |
| { | |
| webBuilder.UseStartup<Startup>(); | |
| }); |
This file contains hidden or 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
| const user = await axios.post(BASE_URL+'/users', data, { auth: { | |
| username: USERNAME, | |
| password: PASSWORD | |
| }}) |
This file contains hidden or 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
| // Manual approach, there is a better way | |
| const token = `${USERNAME}:${PASSWORD}`; | |
| const encodedToken = Buffer.from(token).toString('base64'); | |
| const headers = { 'Authorization': 'Basic '+ encodedToken }; | |
| const user = await axios.post(BASE_URL+'/users', data, { headers }) |
This file contains hidden or 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
| const express = require('express'); | |
| const app = express(); | |
| app.use(express.json()); | |
| app.get('/', (req, res) => { | |
| res.send( { 'ok': true }); | |
| }); | |
| app.listen(3000); |
This file contains hidden or 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
| // npm i axios | |
| const axios = require('axios').default; | |
| axios.interceptors.request.use( x => { | |
| // to avoid overwriting if another interceptor | |
| // already defined the same object (meta) | |
| x.meta = x.meta || {} | |
| x.meta.requestStartedAt = new Date().getTime(); | |
| return x; |
This file contains hidden or 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
| const axios = require('axios').default; | |
| axios.interceptors.request.use( x => { | |
| // to avoid overwriting if another interceptor | |
| // already defined the same object (meta) | |
| x.meta = x.meta || {} | |
| x.meta.requestStartedAt = new Date().getTime(); | |
| return x; | |
| }) |
This file contains hidden or 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
| `{{ctx.periodStart}}` - ` {{ctx.periodEnd}}` | |
| _Total number of warnings_ : {{ctx.results.0.hits.total}} | |
| {{#ctx.results.0.hits.hits}} // Loop over hits | |
| *{{_source.message}}* | |
| _service_: `{{_source.module_name}}` | |
| _traceId_: `{{_source.trace_id}}` |
This file contains hidden or 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
| import { Entity, PrimaryGeneratedColumn, Column } from 'typeorm'; | |
| @Entity() | |
| export class Product { | |
| @PrimaryGeneratedColumn() | |
| id: number; | |
| @Column() | |
| name: string; |
This file contains hidden or 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
| const axios = require('axios').default; | |
| axios.interceptors.request.use(x => { | |
| const headers = { | |
| ...x.headers.common, | |
| ...x.headers[x.method], | |
| ...x.headers | |
| }; |