View notifier.ts
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
class Notifier { | |
private subscribers: ((notification: Notification) => void)[] = []; | |
constructor(subscribers: ((notification: Notification) => void)[]) { | |
this.subscribers = subscribers; | |
} | |
public notify(notification: Notification) { | |
this.subscribers.forEach((subscriber) => subscriber(notification)); | |
} |
View app.js
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
const express = require("express"); | |
const fs = require("fs"); | |
const path = require("path"); | |
const app = express(); | |
const port = process.env.PORT || 3000; | |
const dataFilePath = path.join(__dirname, "data.json"); | |
// Função para ler os dados do arquivo JSON | |
const readData = () => { |
View 0001 - for tradicional.js
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
const items = [1, 2, 3, 4, 5]; | |
const results = []; | |
for (let i = 0; i < items.lenght; i++){ | |
results[i] = items[i]*2; | |
} | |
console.log(results); |
View 0001 - Component v1.js
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
const { useState, useEffect } = React; | |
function App() { | |
const [posts, setPosts] = useState([]); | |
useEffect(() => { | |
axios.get('https://jsonplaceholder.typicode.com/posts').then((res) => { | |
setPosts(res.data.slice(0, 10)); | |
console.log(posts); | |
}); |
View 001 - oop heranca e abstracao.js
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
/* | |
tem rodas | |
anda de ponto a ponto b | |
tem peso | |
*/ | |
class Vehicle { | |
// dado | |
constructor({ | |
model, | |
color, |
View garage-service.spec.js
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
import { mysql } from '@common/connectors/mysql'; | |
import { GarageRepo, GarageService } from '../../src'; | |
const connection = mysql()('Garage'); | |
describe('Garage Service test', () => { | |
it('should GarageService be defined', () => { | |
expect(GarageService).toBeDefined(); |
View garage-service.spec.js
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
import { mysql } from '@common/connectors/mysql'; | |
import { GarageRepo, GarageService } from '../../src'; | |
const connection = mysql()('Garage'); |
View garage-repo.js
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
export default class GarageRepo { | |
constructor(mysql, redis) { | |
this.mysql = mysql; | |
this.redis = redis; | |
} | |
create(attributes) { | |
return this.mysql.create({ | |
input: attributes, | |
}); |
View garage-service.js
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
export default class GarageService { | |
constructor(garageRepo) { | |
this.repository = garageRepo; | |
} | |
async create(data) { | |
return this.repository.create({ | |
...data, | |
id: 'mockid' | |
}) | |
} |
View garage-service.spec.js
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
import { GarageRepo, GarageService } from '../../src'; | |
describe('Garage Service test', () => { | |
it('should GarageService be defined', () => { | |
expect(GarageService).toBeDefined(); | |
}); | |
describe('methods', () => { |
NewerOlder