Skip to content

Instantly share code, notes, and snippets.


Amenallah Hsoumi LazyFatArrow

Block or report user

Report or block LazyFatArrow

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View main.js
import Vue from 'vue'
import App from './App.vue'
import VueCompositionApi from '@vue/composition-api'
Vue.config.productionTip = false
new Vue({
render: h => h(App)
View main.ts
// ...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/')));
View app.module.ts
// ...imports
import { MiddlewareConsumer, Module, NestModule, RequestMethod } from '@nestjs/common';
import { ServeHTMLMiddleware } from './app.middleware';
// ...module options
export class AppModule implements NestModule {
configure(consumer: MiddlewareConsumer) {
View app.middleware.ts
import { Injectable, NestMiddleware } from '@nestjs/common';
import { Request, Response } from 'express';
import { join } from 'path';
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();
View app.controller.ts
import { Controller, Get, Res, Next, Req } from '@nestjs/common';
import { join } from 'path';
import { Response, NextFunction, Request } from 'express';
export class AppController {
@Res() res: Response,
@Next() next: NextFunction,
View index.js
import pollResolvers from './poll.resolvers'
export default {
Query: {
Mutation: {
View Polls.vue
<!-- ...html -->
// ... code
import { OPTION_VOTED, POLL_CREATED } from '@/gql/subscriptions/poll.subscriptions'
// ... code
View poll.subscriptions.js
// ... code
export const POLL_CREATED = gql`
subscription PollCreated {
pollCreated {
options {
View poll.mutations.js
// ... code
export const CREATE_POLL = gql`
mutation createPoll($poll: CreatePollInput!) {
createPoll(poll: $poll) {
View Polls.vue
<b-container class="my-5">
<b-row class="mt-3" v-if="polls && polls.length">
You can’t perform that action at this time.