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 {Injectable} from '@angular/core'; | |
import {Storage} from '@ionic/storage'; | |
import {of, Subject} from 'rxjs'; | |
import {Post} from '../model/Post'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class PostsService { |
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 { Body, Controller, Delete, Get, Param, Post, Put } from '@nestjs/common'; | |
import { UserService } from './user.service'; | |
import { User } from './user.model'; | |
@Controller('user') | |
export class UserController { | |
constructor(private service: UserService) { | |
} | |
@Get('findById/:id') |
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 { Injectable } from '@nestjs/common'; | |
import { InjectModel } from '@nestjs/mongoose'; | |
import { User } from './user.model'; | |
import { Model } from 'mongoose'; | |
@Injectable() | |
export class UserService { | |
constructor( | |
@InjectModel('User') private readonly userModel: Model<User>, | |
) { |
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 { Module } from '@nestjs/common'; | |
import { UserService } from './user.service'; | |
import { UserController } from './user.controller'; | |
import { MongooseModule } from '@nestjs/mongoose'; | |
import { UserSchema } from './user.model'; | |
@Module({ | |
imports: [ | |
MongooseModule.forFeature([{ | |
name: 'User', schema: UserSchema, |
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 * as mongoose from 'mongoose'; | |
export const UserSchema = new mongoose.Schema({ | |
name: { type: String, required: true }, | |
age: { type: Number, required: true }, | |
active: { type: Boolean, required: true }, | |
}); | |
export interface User { | |
id: string; |
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 { Module } from '@nestjs/common'; | |
import { AppController } from './app.controller'; | |
import { AppService } from './app.service'; | |
import { UserModule } from './user/user.module'; | |
import { MongooseModule } from '@nestjs/mongoose'; | |
@Module({ | |
imports: [ | |
MongooseModule.forRoot('mongodb+srv://adsonrocha:<password>@cluster0-5efft.mongodb.net/test?retryWrites=true&w=majority'), | |
UserModule, |
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
'use strict'; | |
const functions = require('firebase-functions'); | |
const nodemailer = require('nodemailer'); | |
const cors = require('cors')({origin: true}); | |
let url = "smtps://<SEU-EMAIL>%40gmail.com:"+encodeURIComponent('<SUA-SENHA>') + "@smtp.gmail.com:465"; | |
let transporter = nodemailer.createTransport(url); | |
exports.enviarEmail = functions.https.onRequest((req, res) => { | |
cors(req, res, () => { |
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 {Component} from '@angular/core'; | |
import * as firebase from 'firebase'; | |
@Component({ | |
selector: 'my-component', | |
templateUrl: 'my-component.html' | |
}) | |
export class FireBaseStorageComponent { | |
fbStorage: any; | |
fileName: string; |