repo_name stringlengths 5 122 | path stringlengths 3 232 | text stringlengths 6 1.05M |
|---|---|---|
kevinelliott/acars-backend | src/leaderboard/leaderboard.service.ts | <filename>src/leaderboard/leaderboard.service.ts<gh_stars>1-10
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { Leaderboard } from '../entities/leaderboard.entity';
@Injectable()
export class LeaderboardService {
construc... |
kevinelliott/acars-backend | src/app.controller.ts | import { Controller, Get, Post, Request, UseGuards } from '@nestjs/common';
import { AppService } from './app.service';
import { LocalAuthGuard } from './auth/local-auth.guard';
import { AuthService } from './auth/auth.service';
import { MailReportService } from './mail_report.service';
import { StationsService } from... |
kevinelliott/acars-backend | src/nats/nats.module.ts | import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { EventsModule } from '../events/events.module';
import { NatsController } from './nats.controller';
import { Message } from '../entities/message.entity';
import { MessageDecoding } from '../entities/message_decoding.entit... |
kevinelliott/acars-backend | src/messages/messages.service.ts | <filename>src/messages/messages.service.ts
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Like, Repository } from 'typeorm';
import { Message } from '../entities/message.entity';
@Injectable()
export class MessagesService {
constructor(
@InjectRepositor... |
kevinelliott/acars-backend | src/flights/flights.module.ts | import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { FlightsController } from './flights.controller';
import { FlightsService } from './flights.service';
import { Flight } from '../entities/flight.entity';
import { OgmaModule } from '@ogma/nestjs-module';
@Module({
imp... |
kevinelliott/acars-backend | src/entities/leaderboard.entity.ts | <filename>src/entities/leaderboard.entity.ts
import {
AfterLoad,
Entity,
Column,
CreateDateColumn,
UpdateDateColumn,
PrimaryGeneratedColumn,
OneToMany,
RelationCount,
ManyToMany,
JoinTable,
Timestamp,
} from 'typeorm';
import { LeaderboardRank } from './leaderboard_rank.entity';
@Entity('leaderb... |
kevinelliott/acars-backend | src/entities/station_message_count.entity.ts | import {
Column,
Entity,
JoinColumn,
PrimaryGeneratedColumn,
OneToOne,
} from 'typeorm';
import { Station } from './station.entity';
@Entity('station_message_counts')
export class StationMessageCount {
@PrimaryGeneratedColumn()
id: number;
@OneToOne(type => Station, station => station.stationMessageC... |
Goytai/NasaAPI | src/shared/graphql/index.ts | import path from 'path';
import Container from 'typedi';
import { ApolloServer } from 'apollo-server';
import { buildSchemaSync } from 'type-graphql';
import { useContainer } from 'typeorm';
const port = Number(process.env.PORT) || 4000;
const schema = buildSchemaSync({
container: Container,
resolvers: [
pat... |
Goytai/NasaAPI | src/modules/planets/services/suitablePlanets.service.ts | import { MongoRepository } from 'typeorm';
import { InjectRepository } from 'typeorm-typedi-extensions';
import { Service } from 'typedi';
import { Stations } from '../../stations/entities/stations.entity';
import { SuitablePlanetsResponse } from '../types/suitablePlanets.type';
import { NasaAPI } from '../../../share... |
Goytai/NasaAPI | src/modules/stations/services/installStation.service.ts | <filename>src/modules/stations/services/installStation.service.ts
import { Service } from 'typedi';
import { MongoRepository } from 'typeorm';
import { InjectRepository } from 'typeorm-typedi-extensions';
import { Stations } from '../entities/stations.entity';
import { InstallStationInput } from '../input/installStati... |
Goytai/NasaAPI | src/modules/stations/services/stations.service.ts | import { Service } from 'typedi';
import { MongoRepository } from 'typeorm';
import { InjectRepository } from 'typeorm-typedi-extensions';
import { Stations } from '../entities/stations.entity';
import { StationsResponse } from '../types/station.type';
@Service()
export class StationsService {
constructor(
@Inj... |
Goytai/NasaAPI | src/modules/stations/stations.resolver.ts | <reponame>Goytai/NasaAPI
import { Arg, Mutation, Query } from 'type-graphql';
import { Service } from 'typedi';
import { InstallStationResponse } from './types/installStation.type';
import { InstallStationInput } from './input/installStation.input';
import { InstallStationService } from './services/installStation.serv... |
Goytai/NasaAPI | src/modules/stations/entities/stations.entity.ts | import {
Column,
CreateDateColumn,
Entity,
ObjectID,
ObjectIdColumn
} from 'typeorm';
@Entity('stations')
export class Stations {
@ObjectIdColumn()
id: ObjectID;
@Column()
planetName: string;
@CreateDateColumn({ type: 'timestamp' })
createdAt: Date;
}
|
Goytai/NasaAPI | src/modules/stations/types/station.type.ts | <reponame>Goytai/NasaAPI
import { Field, ID, ObjectType } from 'type-graphql';
import { ObjectID } from 'typeorm';
@ObjectType()
export class StationsResponse {
@Field(() => ID)
id: ObjectID;
@Field()
planetName: string;
@Field()
createdAt: Date;
}
|
Goytai/NasaAPI | src/shared/rest/index.ts | <filename>src/shared/rest/index.ts<gh_stars>1-10
import { RESTDataSource } from 'apollo-datasource-rest';
import { SuitablePlanetsResponse } from 'modules/planets/types/suitablePlanets.type';
// eslint-disable-next-line import/no-extraneous-dependencies
import { DataSourceConfig } from 'apollo-datasource';
import { Se... |
Goytai/NasaAPI | src/shared/index.ts | <filename>src/shared/index.ts
import 'reflect-metadata';
import './typeorm';
import './graphql';
|
Goytai/NasaAPI | src/modules/planets/planets.resolver.ts | import { Query } from 'type-graphql';
import { Service } from 'typedi';
import { SuitablePlanetsService } from './services/suitablePlanets.service';
import { SuitablePlanetsResponse } from './types/suitablePlanets.type';
@Service()
export class PlanetsResolver {
constructor(
private readonly suitablePlanetsServ... |
Goytai/NasaAPI | src/modules/planets/types/suitablePlanets.type.ts | <filename>src/modules/planets/types/suitablePlanets.type.ts
import { Field, Float, ObjectType } from 'type-graphql';
@ObjectType()
export class SuitablePlanetsResponse {
@Field()
name: string;
@Field(() => Float, { nullable: true })
mass?: number;
@Field()
hasStation: boolean;
}
|
VON-Development-Studio/angular-rest-service | src/lib/von-rest.service.ts | <reponame>VON-Development-Studio/angular-rest-service<filename>src/lib/von-rest.service.ts
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
import { Observable } from 'rxjs';
import { map, share, take } from 'rxjs/operators';
impo... |
VON-Development-Studio/angular-rest-service | src/public-api.ts | <filename>src/public-api.ts
export * from './lib/model/von-error-response.model';
export * from './lib/model/von-error-rest-interceptor.model';
export * from './lib/model/von-page-response.model';
export * from './lib/model/von-page-response.model';
export * from './lib/von-rest-interceptor.service';
export * from './l... |
VON-Development-Studio/angular-rest-service | src/lib/model/von-error-response.model.ts | <reponame>VON-Development-Studio/angular-rest-service<filename>src/lib/model/von-error-response.model.ts
export interface VonErrorResponseModel {
code?: string | null;
message?: string | null;
payload?: any | null;
}
|
VON-Development-Studio/angular-rest-service | src/lib/von-rest-interceptor.service.ts | import { HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest, HttpResponse } from '@angular/common/http';
import { Router } from '@angular/router';
import { Observable, throwError } from 'rxjs';
import { catchError, map } from 'rxjs/operators';
import { VonErrorRestInterceptorModel } from './model/v... |
hasantezcan/PerfAnalytics-Dashboard | src/util/text.utils.tsx | <filename>src/util/text.utils.tsx
import { Tooltip } from 'antd'
/* Function to generate the text inside Tooltip with ellipsis when text exceeds given length */
function getClippedText(text: string, maxLength: number) {
return text.length > maxLength ? (
<Tooltip title={text}>{text.substr(0, maxLength)}...</Tool... |
hasantezcan/PerfAnalytics-Dashboard | src/components/UrlFilter/index.spec.tsx | <gh_stars>1-10
import { render } from '@testing-library/react'
import UrlFilter from '.'
describe('UrlFilter specs', () => {
it('Should render when urls is exist', () => {
let chosenUrls: string[] = ['hasantezcan.dev']
function setChosenUrls(urls: string[]) {
chosenUrls = urls
}
const urls: s... |
hasantezcan/PerfAnalytics-Dashboard | src/components/LineChartWidget/index.tsx | import {
ResponsiveContainer,
LineChart,
Line,
CartesianGrid,
XAxis,
YAxis,
Tooltip
} from 'recharts'
import { Col, Card, Empty } from 'antd'
import { ChartMetric } from '~/models/Metric'
import { stringToColor } from '../../util/color.utils'
import moment from 'moment'
interface LineChartWidgetProps {
... |
hasantezcan/PerfAnalytics-Dashboard | src/factories/metricfactory.tsx | import faker from 'faker'
import { Metric } from '~/models/Metric'
const {
datatype: { number },
lorem: { word }
} = faker
function metricFactory(times: number = 1): Metric[] {
return Array.from({ length: times }, (value, index: number) => {
return {
URL: word(),
UserAgent: word(),
TTFB: n... |
hasantezcan/PerfAnalytics-Dashboard | src/components/TitleWidget/index.spec.tsx | <reponame>hasantezcan/PerfAnalytics-Dashboard<gh_stars>1-10
import { render } from '@testing-library/react'
import TitleWidget from '.'
describe('LineChartWidget specs', () => {
it('Should render', () => {
const { container } = render(<TitleWidget />)
expect(container.getElementsByClassName('ant-typography'... |
hasantezcan/PerfAnalytics-Dashboard | src/service/service.spec.ts | <reponame>hasantezcan/PerfAnalytics-Dashboard<gh_stars>1-10
import axios from './axios'
import sinon, { SinonStub } from 'sinon'
import { waitFor } from '@testing-library/react'
import { metricFactory } from '../factories/metricfactory'
import { urlMetricFactory } from '../factories/urlMetricFactory'
import { fetchMet... |
hasantezcan/PerfAnalytics-Dashboard | src/util/util.spec.tsx | import { lorem } from 'faker'
import { render } from '@testing-library/react'
import { stringToColor } from './color.utils'
import { getClippedText } from './text.utils'
describe('Color specs', () => {
it('Should return #000000 for empty input', () => {
expect(stringToColor('')).toEqual('#000000')
})
it('Sh... |
hasantezcan/PerfAnalytics-Dashboard | src/service/axios.ts | import Axios from 'axios'
const axios = Axios.create({
baseURL: 'https://perfanalytics-api-ht.herokuapp.com',
headers: {
'Content-Type': 'application/json'
}
})
export default axios
|
hasantezcan/PerfAnalytics-Dashboard | src/components/UrlFilter/index.tsx | import { Checkbox, Typography, Form, Empty, Button } from 'antd'
import { getClippedText } from '../../util/text.utils'
const { Title } = Typography
const CheckboxGroup = Checkbox.Group
interface UrlFilterProps {
urls: string[]
onSelect: (urls: string[]) => void
selectedUrls: string[]
}
function UrlFilter({ ur... |
hasantezcan/PerfAnalytics-Dashboard | src/layouts/BaseLayout.tsx | <filename>src/layouts/BaseLayout.tsx
import { PropsWithChildren } from 'react'
import { Layout, Row, Col } from 'antd'
import classNames from 'classnames/bind'
import styles from './styles.module.scss'
const { Footer, Content } = Layout
const cx = classNames.bind(styles)
interface BaseLayoutProps {}
function BaseLay... |
hasantezcan/PerfAnalytics-Dashboard | src/context/AppProviders/index.tsx | import { PropsWithChildren } from 'react'
import { MetricProvider } from '../MetricProvider'
function AppProviders({ children }: PropsWithChildren<any>) {
return <MetricProvider>{children}</MetricProvider>
}
export default AppProviders
|
hasantezcan/PerfAnalytics-Dashboard | src/components/TitleWidget/index.tsx | <filename>src/components/TitleWidget/index.tsx
import { Typography } from 'antd'
import classNames from 'classnames/bind'
import styles from './styles.module.scss'
const { Title } = Typography
const cx = classNames.bind(styles)
function TitleWidget() {
return <Title className={cx('title-widget')}>PerfAnalytics Da... |
hasantezcan/PerfAnalytics-Dashboard | src/routes/Main/Entries/index.tsx | import { useMetricContext } from '~/context/MetricProvider'
import EntriesWidget from '~/components/EntriesWidget'
function Entries() {
const { metrics, selectedUrls } = useMetricContext()
return <EntriesWidget metrics={metrics} selectedUrls={selectedUrls} />
}
export default Entries
|
hasantezcan/PerfAnalytics-Dashboard | src/components/TimeRangeFilter/index.tsx | import { useState } from 'react'
import { DatePicker, TimePicker, Button, Form, Typography } from 'antd'
import moment from 'moment'
const { Title } = Typography
interface TimeRangeFilterProps {
setTimeRange: (start: any, end: any) => void
}
function TimeRangeFilter({ setTimeRange }: TimeRangeFilterProps) {
cons... |
hasantezcan/PerfAnalytics-Dashboard | src/service/index.ts | <gh_stars>1-10
import axios from './axios'
import { Metric, MetricByURL } from '~/models/Metric'
async function fetchMetricByTimeRange(start?: Date, end?: Date) {
const { data } = await axios.get('/api/metrics', {
params: {
start,
end
}
})
return data as Metric[]
}
async function fetchMetri... |
hasantezcan/PerfAnalytics-Dashboard | src/routes/Main/Filter/index.tsx | import { useEffect } from 'react'
import { Row, Col, Card } from 'antd'
import TimeRangeFilter from '@components/TimeRangeFilter/index'
import UrlFilter from '~/components/UrlFilter'
import { fetchMetricByTimeRange, fetchMetricByURL } from '~/service'
import { useMetricContext } from '~/context/MetricProvider'
functi... |
hasantezcan/PerfAnalytics-Dashboard | src/components/TimeRangeFilter/index.spec.tsx | import { render, fireEvent, waitFor } from '@testing-library/react'
import sinon, { SinonSpy } from 'sinon'
import TimeRangeFilter from '.'
const sandbox = sinon.createSandbox()
describe('TimeRangeFilter specs', () => {
const handleTimeRange = (start: any, end: any) => {}
let handleTimeRangeSpy: SinonSpy
befo... |
hasantezcan/PerfAnalytics-Dashboard | src/models/Metric.ts | interface MetricTypes {
TTFB: string
FCP: string
DomLoad: string
WindowLoad: string
}
type MetricType = keyof MetricTypes
interface Metric {
URL: string
UserAgent: string
TTFB: number
FCP: number
DomLoad: number
WindowLoad: number
Entries: Entry[]
createdAt: Date
_id: string
}
interface Tim... |
hasantezcan/PerfAnalytics-Dashboard | src/context/MetricProvider.tsx | import {
createContext,
useContext,
PropsWithChildren,
useState,
useEffect,
Dispatch,
SetStateAction
} from 'react'
import { Metric, MetricByURL } from '../models/Metric'
import { fetchMetricByTimeRange, fetchMetricByURL } from '../service'
interface MetricContextModel {
metrics: Metric[]
setMetrics... |
hasantezcan/PerfAnalytics-Dashboard | src/components/LineChartWidget/index.spec.tsx | import { render, waitFor } from '@testing-library/react'
import LineChartWidget from '.'
import { ChartMetric } from '~/models/Metric'
import { chartMetricFactory } from '../../factories/chartMetricFactory'
import moment from 'moment'
describe('LineChartWidget specs', () => {
let data: ChartMetric[]
beforeEach((... |
hasantezcan/PerfAnalytics-Dashboard | src/routes/Main/index.tsx | <gh_stars>1-10
import { Row, Col } from 'antd'
import BaseLayout from '~/layouts/BaseLayout'
import PerfCharts from './PerfCharts'
import Filter from './Filter'
import Entries from './Entries/index'
import TitleWidget from '~/components/TitleWidget'
function Main() {
return (
<BaseLayout>
<Row gutter={[16... |
hasantezcan/PerfAnalytics-Dashboard | src/App.tsx | <filename>src/App.tsx<gh_stars>1-10
import AppProviders from '~/context/AppProviders'
import Main from '~/routes/Main'
import '~/styles/App.less'
function App() {
return (
<AppProviders>
<Main />
</AppProviders>
)
}
export default App
|
hasantezcan/PerfAnalytics-Dashboard | src/routes/Main/PerfCharts/index.tsx | <reponame>hasantezcan/PerfAnalytics-Dashboard
import { Row } from 'antd'
import LineChartWidget from '@components/LineChartWidget'
import { useMetricContext } from '~/context/MetricProvider'
import { ChartMetric, MetricType, TimeStampValue } from '~/models/Metric'
function PerfCharts() {
const { urlMetrics, selecte... |
hasantezcan/PerfAnalytics-Dashboard | src/components/EntriesWidget/index.tsx | import { useState } from 'react'
import { Table, Typography } from 'antd'
import moment from 'moment'
import { getClippedText } from '../../util/text.utils'
import { Metric } from '~/models/Metric'
import './style.css'
const { Title } = Typography
interface EntriesWidgetProps {
metrics: Metric[]
selectedUrls: st... |
hasantezcan/PerfAnalytics-Dashboard | src/factories/chartMetricFactory.tsx | <filename>src/factories/chartMetricFactory.tsx
import faker from 'faker'
import { ChartMetric } from '~/models/Metric'
const {
datatype: { number },
lorem: { word },
date: { past }
} = faker
function chartMetricFactory(times: number = 1): ChartMetric[] {
return Array.from({ length: times }, (index: number) =>... |
hasantezcan/PerfAnalytics-Dashboard | src/factories/urlMetricFactory.tsx | import faker from 'faker'
import { MetricByURL } from '~/models/Metric'
const {
datatype: { number },
lorem: { word },
date: { past }
} = faker
function urlMetricFactory(times: number = 1): MetricByURL[] {
return Array.from({ length: times }, (index: number) => {
return {
URL: word(),
TTFB: Ar... |
hasantezcan/PerfAnalytics-Dashboard | src/components/EntriesWidget/index.spec.tsx | import { render, fireEvent, waitFor } from '@testing-library/react'
import EntriesWidget from '.'
import { Metric } from '~/models/Metric'
import { metricFactory } from '../../factories/metricfactory'
describe('EntriesWidget specs', () => {
let metrics: Metric[]
let chosenUrls: string[]
beforeEach(() => {
... |
supersoniko/aws-secrets-dotenv | src/__tests__/secrets-manager.ts | <reponame>supersoniko/aws-secrets-dotenv
import SecretsManager from 'aws-sdk/clients/secretsmanager';
import fs from 'fs';
import secretsManagerFunctionFactoryImpl from '../secrets-manager';
import { Config, SecretManagerFunctionFactory } from '../types';
describe('SecretsManagerFunctionFactory', (): void => {
let s... |
supersoniko/aws-secrets-dotenv | src/types.ts | export interface Config {
Name: string;
Description: string;
SecretString: string;
}
export interface SecretManagerFunctionFactory {
createOrUpdateSecret: (stage?: string) => Promise<void>;
createLocalEnvironment: (stage?: string) => Promise<void>;
}
|
supersoniko/aws-secrets-dotenv | src/index.ts | #!/usr/bin/env node
import AWS from 'aws-sdk';
import fs from 'fs';
AWS.config.update({ region: process.env.AWS_DEFAULT_REGION });
import secretsManagerFunctionFactory from './secrets-manager';
import getConfig from './get-config';
const secretsManager = new AWS.SecretsManager();
const config = getConfig('secrets')... |
WrathChaos/react-native-dynamic-rate | example/App.style.ts | import { ViewStyle, TextStyle, StyleSheet, Dimensions } from "react-native";
const { width: ScreenWidth } = Dimensions.get("window");
interface Style {
container: ViewStyle;
titleContainer: ViewStyle;
titleTextStyle: TextStyle;
cardsExampleContainer: ViewStyle;
cardStyle: ViewStyle;
dividerStyle: ViewStyle... |
WrathChaos/react-native-dynamic-rate | example/App.tsx | <gh_stars>0
import * as React from "react";
import { View, Text, StatusBar, SafeAreaView } from "react-native";
import DynamicRate from "./lib/DynamicRate";
/**
* ? Local Imports
*/
import styles from "./App.style";
interface IProps {}
interface IState {
rate: number;
value: number;
}
class App extends React.... |
vv13/leetcode-problems-crawler | src/index.ts | #!/usr/bin/env node
import program from 'commander'
import path from 'path'
import request from 'superagent'
import config from './config'
import { IPair } from './types'
import {
writeDirectory,
writeInformation,
writeQuestion,
writeSolution
} from './utils'
program
.name('leetcode-problem-crawler')
.opt... |
vv13/leetcode-problems-crawler | src/config.ts | <reponame>vv13/leetcode-problems-crawler
import path from 'path'
export default {
cn: {
domain: 'https://leetcode-cn.com'
},
en: {
domain: 'https://leetcode.com'
},
DEFAULT_DIRNAME: 'problems',
langSlugMap: {
csharp: '.cs',
java: '.java',
javascript: '.js',
php: '.php',
python: ... |
vv13/leetcode-problems-crawler | src/types.ts | export interface IPair {
difficulty: { level: number },
stat: {
frontend_question_id: number,
question__title_slug: string
}
}
|
vv13/leetcode-problems-crawler | src/utils.ts | import fs from 'fs'
import path from 'path'
import config from './config'
export function writeDirectory(dirname: string) {
if (!fs.existsSync(dirname)) {
fs.mkdirSync(dirname, { recursive: true })
}
}
export function writeQuestion(dirname: string, questionConfig: any) {
const filePath = path.join(
dirn... |
markylaing/nauth0 | packages/nauth0/src/server/index.ts | import { NextApiHandler, NextApiRequest } from 'next';
import { GetSessionOpts, NAuth0Client } from '../client';
import { NAuth0Options } from './config';
import { Session } from '../lib';
import routes from './routes';
import { getSessionFromReq } from './session';
class ServerNAuth0Client implements NAuth0Client {
... |
markylaing/nauth0 | packages/nauth0/src/browser/useSession.ts | import { useContext, useEffect, useState } from 'react';
import { Session } from '../lib';
import { SessionContext } from './SessionProvider';
import fetch from 'unfetch';
export const useSession = (): [Session, boolean] => {
const ssrSession = useContext(SessionContext);
if (ssrSession) {
return [ssrSession,... |
markylaing/nauth0 | packages/nauth0/src/index.browser.ts | <reponame>markylaing/nauth0<filename>packages/nauth0/src/index.browser.ts
import BrowserNAuth0Client from './browser';
import { NAuth0Client } from './client';
export default (): NAuth0Client => {
return new BrowserNAuth0Client();
};
export * from './browser';
export * from './lib';
|
markylaing/nauth0 | packages/nauth0/src/server/routes/session.ts | <reponame>markylaing/nauth0<filename>packages/nauth0/src/server/routes/session.ts
import { NAuth0ApiRoute } from './route';
import { getSessionFromReq } from '../../server/session';
export const sessionRoute: NAuth0ApiRoute = async (req, res, opts) => {
const session = await getSessionFromReq({ req }, opts);
if (... |
markylaing/nauth0 | packages/nauth0/src/server/routes/login.ts | <gh_stars>0
import { NAuth0ApiRoute } from './route';
import { createClient, createState } from '../oidc';
import { setCookie } from 'nookies';
import { stateCookie } from '../cookies';
export const loginRoute: NAuth0ApiRoute = async (req, res, opts) => {
const client = await createClient(opts);
const state = crea... |
markylaing/nauth0 | packages/nauth0/src/server/routes/logout.ts | import { destroyCookie } from 'nookies';
import { sessionCookie, stateCookie } from '../cookies';
import { NAuth0ApiRoute } from './route';
export const logoutRoute: NAuth0ApiRoute = async (req, res, opts) => {
// TODO: This is very auth0 specific. If we want to make this work with any OIDC provider then it needs to... |
markylaing/nauth0 | example/cypress/integration/login.spec.ts | <gh_stars>1-10
describe('Login', () => {
beforeEach(() => {
cy.clearCookies();
});
it('sets the state cookie', () => {
cy.request('api/auth/login');
cy.getCookie('nauth0:state').should('exist');
});
});
|
markylaing/nauth0 | packages/nauth0/src/lib/session.ts | <filename>packages/nauth0/src/lib/session.ts
import { User } from './user';
export interface Session {
user?: User;
accessToken?: string;
}
|
markylaing/nauth0 | example/pages/api/auth/[auth].ts | import nauth0 from 'lib/nauth0';
export default nauth0.handler();
|
markylaing/nauth0 | packages/nauth0/src/browser/index.ts | import { Session } from '../lib';
import { NAuth0Client } from '../client';
import { NextApiHandler } from 'next';
class BrowserNAuth0Client implements NAuth0Client {
handler(): NextApiHandler {
throw new Error('Handler only implemented for the server');
}
getSession(): Promise<Session> {
throw new Erro... |
markylaing/nauth0 | packages/nauth0/src/server/routes/index.ts | <filename>packages/nauth0/src/server/routes/index.ts
import { callbackRoute } from './callback';
import { loginRoute } from './login';
import { logoutRoute } from './logout';
import { notFoundRoute } from './notFound';
import { NAuth0ApiRoute } from './route';
import { sessionRoute } from './session';
export default (... |
markylaing/nauth0 | example/pages/_app.tsx | import React from 'react';
import type { AppProps } from 'next/app';
import { SessionProvider } from 'nauth0';
function App({ Component, pageProps }: AppProps): JSX.Element {
return (
<SessionProvider value={pageProps.session}>
<Component {...pageProps} />
</SessionProvider>
);
}
export default App;... |
markylaing/nauth0 | example/pages/index.tsx | <gh_stars>1-10
import React from 'react';
import { useSession } from 'nauth0';
const Home: React.FC = () => {
const [session, isLoading] = useSession();
if (isLoading) {
return <div>Loading...</div>;
}
const { user } = session;
if (!user) {
return <a href="/api/auth/login">Login</a>;
}
return... |
markylaing/nauth0 | packages/nauth0/src/browser/SessionProvider.ts | <gh_stars>1-10
import React from 'react';
import { Session } from '../lib';
export const SessionContext = React.createContext<Session | undefined>(
undefined
);
export const SessionProvider = SessionContext.Provider;
|
markylaing/nauth0 | packages/nauth0/src/server/routes/callback.ts | import { NAuth0ApiRoute } from './route';
import { parseCookies, setCookie } from 'nookies';
import { sessionCookie, stateCookie } from '../cookies';
import { createClient } from '../oidc';
import { encodeSession, sessionFromTokenSet } from '../session';
export const callbackRoute: NAuth0ApiRoute = async (req, res, op... |
markylaing/nauth0 | packages/nauth0/src/server/routes/notFound.ts | import { NAuth0ApiRoute } from './route';
export const notFoundRoute: NAuth0ApiRoute = (req, res) => {
res.status(404).end();
};
|
markylaing/nauth0 | example/lib/nauth0.ts | <filename>example/lib/nauth0.ts
import nauth0 from 'nauth0';
export default nauth0({
domain: process.env.AUTH0_DOMAIN,
clientId: process.env.AUTH0_CLIENT_ID,
clientSecret: process.env.AUTH0_CLIENT_SECRET,
redirectUri: 'http://localhost:3000/api/auth/callback',
logoutRedirectUri: 'http://localhost:3000/',
s... |
markylaing/nauth0 | packages/nauth0/src/index.ts | <filename>packages/nauth0/src/index.ts<gh_stars>0
import BrowserNAuth0Client from './browser';
import { NAuth0Client } from './client';
import ServerNAuth0Client, { NAuth0Options } from './server';
export default (opts: NAuth0Options): NAuth0Client => {
const isBrowser = typeof window !== 'undefined';
if (isBrows... |
markylaing/nauth0 | packages/nauth0/src/server/session.ts | import { TokenSet } from 'openid-client';
import { NAuth0Options } from './config';
import { Session } from '../lib';
import SignJWT from 'jose/jwt/sign';
import jwtVerify from 'jose/jwt/verify';
import { parseCookies } from 'nookies';
import { sessionCookie } from './cookies';
import { GetSessionOpts } from '../client... |
markylaing/nauth0 | packages/nauth0/src/server/oidc.ts | <gh_stars>0
import base64url from 'base64url';
import { randomBytes } from 'crypto';
import { Client, Issuer } from 'openid-client';
import { NAuth0Options } from './config';
export const createState = (
stateObject: Record<string, unknown> = {}
): string => {
stateObject.nonce = createNonce();
return encodeStat... |
markylaing/nauth0 | packages/nauth0/src/server/config.ts | export interface NAuth0Options {
domain: string;
clientId: string;
clientSecret: string;
scope: string;
redirectUri: string;
logoutRedirectUri: string;
audience?: string;
session: {
cookieSecret: string;
cookieLifetime?: number;
};
}
|
markylaing/nauth0 | packages/nauth0/src/server/cookies.ts | export const stateCookie = 'nauth0:state';
export const sessionCookie = 'nauth0:session';
|
markylaing/nauth0 | packages/nauth0/src/client.ts | import { NextApiHandler, NextApiRequest, NextPageContext } from 'next';
import { Session } from './lib';
export type GetSessionOpts =
| Pick<NextPageContext, 'req'>
| {
req: NextApiRequest;
};
export interface NAuth0Client {
handler(): NextApiHandler;
getSession(req: GetSessionOpts): Promise<Session... |
markylaing/nauth0 | example/pages/ssr.tsx | <gh_stars>1-10
import React from 'react';
import { useSession } from 'nauth0';
import { GetServerSideProps } from 'next';
import nauth0 from 'lib/nauth0';
const Home: React.FC = () => {
const [session] = useSession();
const { user } = session;
return (
<code>
<pre>{JSON.stringify(user)}</pre>
</c... |
markylaing/nauth0 | packages/nauth0/src/browser/useSession.test.tsx | import React from 'react';
import { render, screen, waitFor } from '@testing-library/react';
import { useSession } from './useSession';
import { SessionProvider } from './SessionProvider';
import { rest } from 'msw';
import { setupServer } from 'msw/node';
import { Session } from '../lib';
import '@testing-library/jest... |
markylaing/nauth0 | packages/nauth0/src/lib/index.ts | export * from './session';
export * from './user';
|
markylaing/nauth0 | packages/nauth0/src/server/routes/route.ts | <reponame>markylaing/nauth0<filename>packages/nauth0/src/server/routes/route.ts<gh_stars>0
import { NextApiRequest, NextApiResponse } from 'next';
import { NAuth0Options } from '../config';
export type NAuth0ApiRoute = (
req: NextApiRequest,
res: NextApiResponse,
cfg: NAuth0Options
) => void | Promise<void>;
|
bhavyaw/connected | src/connected.ts | <reponame>bhavyaw/connected
import PubSub from "./pubSub"
class Connected extends PubSub {
constructor() {
super()
console.log(this)
}
}
new Connected()
|
bhavyaw/connected | src/pubSub.ts | <reponame>bhavyaw/connected
export default class PubSub {
_events = {}
constructor() {
console.log("inside pubsub constructor")
}
}
|
aequasi/fluent-behavior-tree | src/BehaviorTreeBuilder.ts | <reponame>aequasi/fluent-behavior-tree
import Stack from "ts-data.stack";
import BehaviorTreeStatus from "./BehaviorTreeStatus";
import BehaviorTreeError from "./Error/BehaviorTreeError";
import Errors from "./Error/Errors";
import ActionNode from "./Node/ActionNode";
import BehaviorTreeNodeInterface from "./Node/Behav... |
aequasi/fluent-behavior-tree | test/Node/InverterNodeTest.ts | <gh_stars>10-100
import test from "ava";
import * as TypeMoq from "typemoq";
import StateData from "../../src/StateData";
import InverterNode from "../../src/Node/InverterNode";
import BehaviorTreeNodeInterface from "../../src/Node/BehaviorTreeNodeInterface";
import BehaviorTreeStatus from "../../src/BehaviorTreeStatus... |
aequasi/fluent-behavior-tree | src/index.ts | import BehaviorTreeBuilder from "./BehaviorTreeBuilder";
import BehaviorTreeStatus from "./BehaviorTreeStatus";
import BehaviorTreeErorr from "./Error/BehaviorTreeError";
import Errors from "./Error/Errors";
import ActionNode from "./Node/ActionNode";
import BehaviorTreeNodeInterface from "./Node/BehaviorTreeNodeInterf... |
aequasi/fluent-behavior-tree | test/Node/SequenceNodeTest.ts | <filename>test/Node/SequenceNodeTest.ts
import test from "ava";
import * as TypeMoq from "typemoq";
import StateData from "../../src/StateData";
import BehaviorTreeNodeInterface from "../../src/Node/BehaviorTreeNodeInterface";
import BehaviorTreeStatus from "../../src/BehaviorTreeStatus";
import SequenceNode from "../.... |
aequasi/fluent-behavior-tree | src/Node/ActionNode.ts | import BehaviorTreeStatus from "../BehaviorTreeStatus";
import BehaviorTreeError from "../Error/BehaviorTreeError";
import Errors from "../Error/Errors";
import StateData from "../StateData";
import BehaviorTreeNodeInterface from "./BehaviorTreeNodeInterface";
/**
* A behavior tree leaf node for running an action
*
... |
KidDevelopper/disc-11 | src/events/WarnEvent.ts | import { BaseEvent } from "../structures/BaseEvent";
export class WarnEvent extends BaseEvent {
public constructor(client: BaseEvent["client"]) {
super(client, "warn");
}
public execute(warn: string): void {
this.client.logger.warn("CLIENT_WARN:", warn);
}
}
|
KidDevelopper/disc-11 | src/events/DebugEvent.ts | import { BaseEvent } from "../structures/BaseEvent";
export class DebugEvent extends BaseEvent {
public constructor(client: BaseEvent["client"]) {
super(client, "debug");
}
public execute(message: string): void {
this.client.logger.debug(message);
}
}
|
KidDevelopper/disc-11 | src/events/ChannelUpdateEvent.ts | import { BaseEvent } from "../structures/BaseEvent";
import { createEmbed } from "../utils/createEmbed";
import { entersState, VoiceConnectionStatus } from "@discordjs/voice";
import { GuildChannel, VoiceChannel } from "discord.js";
import i18n from "i18n";
export class ChannelUpdateEvent extends BaseEvent {
publi... |
KidDevelopper/disc-11 | src/commands/music/VolumeCommand.ts | import { inVC, sameVC, validVC } from "../../utils/decorators/MusicUtil";
import { CommandContext } from "../../structures/CommandContext";
import { BaseCommand } from "../../structures/BaseCommand";
import { createEmbed } from "../../utils/createEmbed";
import i18n from "../../config";
import { AudioPlayerPlayingState... |
KidDevelopper/disc-11 | src/config.ts | import { IpresenceData } from "./typings";
import { ActivityType, ClientOptions, ClientPresenceStatus, Intents, LimitedCollection, Options, ShardingManagerMode } from "discord.js";
import { join } from "path";
import i18n from "i18n";
export const clientOptions: ClientOptions = {
allowedMentions: { parse: ["users"... |
KidDevelopper/disc-11 | src/utils/decorators/MusicUtil.ts | import { CommandContext } from "../../structures/CommandContext";
import { createEmbed } from "../createEmbed";
import i18n from "../../config";
export function haveQueue(ctx: CommandContext): boolean {
if (!ctx.guild?.queue) {
void ctx.reply({ embeds: [createEmbed("warn", i18n.__("utils.musicDecorator.noQ... |
KidDevelopper/disc-11 | src/typings/index.d.ts | import { CommandContext } from "../structures/CommandContext";
import { ServerQueue } from "../structures/ServerQueue";
import { Disc } from "../structures/Disc";
import { ActivityType, ApplicationCommandOptionData, ApplicationCommandType, ClientEvents, ClientPresenceStatus, Client as OClient, Collection, GuildMember,... |
KidDevelopper/disc-11 | src/events/ErrorEvent.ts | import { BaseEvent } from "../structures/BaseEvent";
export class ErrorEvent extends BaseEvent {
public constructor(client: BaseEvent["client"]) {
super(client, "error");
}
public execute(error: string): void {
this.client.logger.error("CLIENT_ERROR:", error);
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.