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(); | |
const port = 3000; | |
app.listen(port, () => { | |
console.log(`Server running on port ${port}`); | |
}); |
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(); | |
const port = 3000; | |
const axios = require('axios'); | |
app.get('/recipe/:fooditem', async (req, res) => { | |
try { |
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 axios = require('axios'); | |
const redis = require('redis'); | |
const app = express(); | |
const port = 3000; | |
// make a connection to the local instance of redis | |
const client = redis.createClient(6379); |
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 bodyParser = require('body-parser'); | |
const app = express(); | |
app.use(bodyParser.urlencoded({ extended: false })); | |
app.use(bodyParser.json()); | |
const port = 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
require('dotenv').config(); | |
const accountSid = process.env.TWILIO_ACCOUNT_SID; | |
const authToken = process.env.TWILIO_AUTH_TOKEN; | |
const sendSms = (phone, message) => { | |
const client = require('twilio')(accountSid, authToken); | |
client.messages | |
.create({ | |
body: message, |
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 bodyParser = require('body-parser'); | |
const sendSms = require('./twilio'); | |
const app = express(); | |
app.use(bodyParser.urlencoded({ extended: false })); | |
app.use(bodyParser.json()); |
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 { PassportStrategy } from '@nestjs/passport'; | |
import { Strategy, VerifyCallback } from 'passport-google-oauth20'; | |
import { config } from 'dotenv'; | |
import { Injectable } from '@nestjs/common'; | |
config(); | |
@Injectable() | |
export class GoogleStrategy extends PassportStrategy(Strategy, 'google') { |
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 { Controller, Get, Req, UseGuards } from '@nestjs/common'; | |
import { AppService } from './app.service'; | |
import { AuthGuard } from '@nestjs/passport'; | |
@Controller('google') | |
export class AppController { | |
constructor(private readonly appService: AppService) {} | |
@Get() | |
@UseGuards(AuthGuard('google')) |
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 { Injectable } from '@nestjs/common'; | |
@Injectable() | |
export class AppService { | |
googleLogin(req) { | |
if (!req.user) { | |
return 'No user from google' | |
} | |
return { |
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 { Module } from '@nestjs/common'; | |
import { AppController } from './app.controller'; | |
import { AppService } from './app.service'; | |
import { GoogleStrategy } from './google.strategy' | |
@Module({ | |
imports: [], | |
controllers: [AppController], | |
providers: [AppService, GoogleStrategy], | |
}) |
OlderNewer