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, Post, Body} from '@nestjs/common'; | |
import { PostsService } from './posts.service'; | |
import { CreatePostDto } from './dto/create-post.dto'; | |
@Controller('posts') | |
export class PostsController { | |
constructor(private readonly postsService: PostsService) {} | |
// endpoint for create new post | |
@Post() |
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, Post, Body} from '@nestjs/common'; | |
import { UsersService } from './users.service'; | |
import { CreateUserDto } from './dto/create-user.dto'; | |
@Controller('users') | |
export class UsersController { | |
constructor(private readonly usersService: UsersService) {} | |
// endpoint for create new user | |
@Post() |
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, Post, Body } from '@nestjs/common'; | |
import { UserpostsService } from './userposts.service'; | |
import { CreateUserDto } from 'src/users/dto/create-user.dto'; | |
import { CreatePostDto } from 'src/posts/dto/create-post.dto'; | |
/* | |
This approach is not recommended because this controller class is | |
responsible for handling users and posts endpoints............. | |
Violates Single Responsibility Principle..................... | |
*/ |
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 React from 'react' | |
import TimeCard from './TimeCard' | |
async function getDateTime() { | |
const res = await fetch(`https://worldtimeapi.org/api/ip`, { next: { revalidate: 20 } }) | |
return res.json() | |
} | |
export default async function ISR() { | |
const result = await getDateTime() |
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 React from 'react' | |
import TimeCard from './TimeCard' | |
async function getDateTime() { | |
const res = await fetch(`https://worldtimeapi.org/api/ip`,{cache: 'force-cache'}) | |
return res.json() | |
} | |
export default async function SSG() { | |
const result = await getDateTime() | |
const dateTime = result.datetime |
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 React from 'react' | |
import TimeCard from './TimeCard' | |
async function getDateTime() { | |
const res = await fetch(`https://worldtimeapi.org/api/ip`, { cache: 'no-store' }) | |
return res.json() | |
} | |
export default async function SSR() { | |
const result = await getDateTime() |
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
'use client'; // Disable server-side rendering with this statement in the component file | |
import React from 'react' | |
import TimeCard from './TimeCard' | |
import axios from 'axios'; | |
import { useState, useEffect } from 'react' | |
export default function CSR() { | |
const [dateTime, setDateTime] = useState(''); | |
useEffect(() => { | |
axios | |
.get('https://worldtimeapi.org/api/ip') // Make a request for take the date and time from the API |
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
// Creating an endpoint for sending customized emails | |
app.post('/customized-email',(req, res)=>{ | |
let config = { | |
service: 'gmail', | |
auth: { | |
user: process.env.NODEJS_GMAIL_APP_USER, | |
pass: process.env.NODEJS_GMAIL_APP_PASSWORD | |
} | |
} | |
let transporter = nodemailer.createTransport(config); |
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 nodemailer = require('nodemailer'); | |
const Mailgen = require('mailgen'); | |
require('dotenv').config(); | |
const app = express(); | |
const port = 3001; | |
app.use(express.json()); | |
app.post('/email',(req, res)=>{ |
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 = 3001; | |
require('dotenv').config(); | |
app.use(express.json()); | |
app.post('/email',(req, res)=>{ | |
}) |
NewerOlder