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 { shallowMount } from '@vue/test-utils' | |
import { beforeEach, describe, test, vi, expect } from 'vitest' | |
import { useRouter } from 'vue-router' | |
import { RouteNames, router } from '../../router/router' | |
import Home from './Home.vue' | |
vi.mock('vue-router') | |
describe('Home', () => { | |
vi.mocked(useRouter).mockReturnValue({ |
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 Vue from 'vue' | |
import App from './App.vue' | |
import VueCompositionApi from '@vue/composition-api' | |
Vue.config.productionTip = false | |
Vue.use(VueCompositionApi) | |
new Vue({ | |
render: h => h(App) |
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
// ...imports | |
import * as express from 'express'; | |
import { join } from 'path'; | |
async function bootstrap() { | |
const app = await NestFactory.create(AppModule); | |
// serve static assets from the client/dist folder, change this to the correct path for your project | |
app.use(express.static(join(process.cwd(), '../client/dist/'))); | |
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
// ...imports | |
import { MiddlewareConsumer, Module, NestModule, RequestMethod } from '@nestjs/common'; | |
import { ServeHTMLMiddleware } from './app.middleware'; | |
@Module({ | |
// ...module options | |
}) | |
export class AppModule implements NestModule { | |
configure(consumer: MiddlewareConsumer) { | |
consumer |
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, NestMiddleware } from '@nestjs/common'; | |
import { Request, Response } from 'express'; | |
import { join } from 'path'; | |
@Injectable() | |
export class ServeHTMLMiddleware implements NestMiddleware { | |
use(req: Request, res: Response, next: () => void) { | |
// here you can check if the requested path is your api endpoint, if that's the case then we have to return next() | |
if (req.path.includes('graphql')) { | |
return next(); |
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 { Controller, Get, Res, Next, Req } from '@nestjs/common'; | |
import { join } from 'path'; | |
import { Response, NextFunction, Request } from 'express'; | |
@Controller() | |
export class AppController { | |
@Get('*') | |
get( | |
@Res() res: Response, | |
@Next() next: NextFunction, |
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 pollResolvers from './poll.resolvers' | |
export default { | |
Query: { | |
...pollResolvers.queries | |
}, | |
Mutation: { | |
...pollResolvers.mutations | |
}, |
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
<template> | |
<!-- ...html --> | |
</template> | |
<script> | |
// ... code | |
import { OPTION_VOTED, POLL_CREATED } from '@/gql/subscriptions/poll.subscriptions' | |
// ... code |
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
// ... code | |
export const POLL_CREATED = gql` | |
subscription PollCreated { | |
pollCreated { | |
id | |
title | |
description | |
options { | |
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
// ... code | |
export const CREATE_POLL = gql` | |
mutation createPoll($poll: CreatePollInput!) { | |
createPoll(poll: $poll) { | |
id | |
} | |
} | |
`; |
NewerOlder