repo_name stringlengths 5 122 | path stringlengths 3 232 | text stringlengths 6 1.05M |
|---|---|---|
rdkmaster/any-badge | app/any-badge/web/src/app/badges/badges.component.ts | import 'rxjs/add/operator/switchMap';
import {AfterViewInit, Component, OnDestroy, OnInit, Renderer2, TemplateRef, ViewChild} from '@angular/core';
import {
JigsawErrorAlert, JigsawInput, LoadingService, PopupInfo, PopupOptions,
PopupService, TableCellRendererBase, TableCellTextEditorRenderer,
TableData, Tab... |
rdkmaster/any-badge | app/any-badge/web/src/app/front-page/front-page.module.ts | <reponame>rdkmaster/any-badge
import {NgModule} from "@angular/core";
import {RouterModule} from "@angular/router";
import {JigsawButtonModule} from "@rdkmaster/jigsaw";
import {FrontPageComponent} from "./front-page.component";
import {AuthService} from "../services/auth.service";
@NgModule({
imports: [Route... |
ticlo/server-example | src/multi-server-example/main.ts | <reponame>ticlo/server-example
import Express from 'express';
import {Root} from '@ticlo/core';
import {connectTiclo, routeTiclo, getEditorUrl} from '@ticlo/express';
import {FileJobLoader} from '@ticlo/node';
// save load jobs from the same folder
Root.instance.setLoader(new FileJobLoader('./src/multi-server-example'... |
ticlo/server-example | src/custom-function-example/group-input-function.ts | <gh_stars>0
import {Functions, BaseFunction} from '@ticlo/core';
// sort input string and output an array
class SortStringFunction extends BaseFunction {
run(): any {
let len = this._data.getLength();
if (!(len >= 0)) {
len = 2;
}
let arr: any[] = [];
for (let i = 0; i < len; ++i) {
l... |
ticlo/server-example | src/custom-function-example/oncall-function.ts | import {Functions, BaseFunction} from '@ticlo/core';
import Moment from 'moment';
// sort input string and output an array
class GetTimeFunction extends BaseFunction {
run(): any {
this._data.output(Moment());
}
}
Functions.add(
GetTimeFunction,
{
name: 'get-time',
icon: 'fas:clock', // icon from ... |
ticlo/server-example | src/custom-function-example/async-function.ts | <reponame>ticlo/server-example
import {Functions, BaseFunction} from '@ticlo/core';
// sort input string and output an array
class SortStringFunction extends BaseFunction {
run(): any {
let delay = this._data.getValue('delay');
if (delay > 0) {
return new Promise((resolve) => {
setTimeout(() =>... |
ticlo/server-example | src/route-example/main.ts | <reponame>ticlo/server-example<filename>src/route-example/main.ts
import Express from 'express';
import {Root} from '@ticlo/core';
import {connectTiclo, routeTiclo, getEditorUrl} from '@ticlo/express';
import {FileJobLoader} from '@ticlo/node';
// save load jobs from the same folder
Root.instance.setLoader(new FileJob... |
ticlo/server-example | src/basic-example/main.ts | <reponame>ticlo/server-example
import Express from 'express';
import {Root} from '@ticlo/core';
import {FileJobLoader} from '@ticlo/node';
import {connectTiclo, getEditorUrl} from '@ticlo/express';
// save load jobs from the the same folder
Root.instance.setLoader(new FileJobLoader('./src/basic-example'));
let app = ... |
Atokulus/zigbee-herdsman | src/adapter/ezsp/driver/uart.ts | <filename>src/adapter/ezsp/driver/uart.ts
/* istanbul ignore file */
import {EventEmitter} from 'events';
import {SerialPort} from 'serialport';
import net from 'net';
import SocketPortUtils from '../../socketPortUtils';
import {Deferred, crc16ccitt} from './utils';
import * as stream from 'stream';
import {Queu... |
rohail0/tfjs | tfjs-core/src/ops/ops.ts | <gh_stars>0
/**
* @license
* Copyright 2020 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless r... |
rohail0/tfjs | tfjs-core/src/public/chained_ops/register_all_chained_ops_test.ts | /**
* @license
* Copyright 2018 Google LLC. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by a... |
IBM-Z/zos-hot-topics | api/survey.ts | import { VercelRequest, VercelResponse } from '@vercel/node'
//import fetch, { FetchError } from 'node-fetch';
import { WebClient } from '@slack/web-api';
require('dotenv').config();
const permittedOrigins = [
'https://zoshottopics.gatsbyjs.io',
'https://www.zos-hot-topics.com',
'https://zoshottopics.vercel.ap... |
leodaiub/cybergamer-challenge | src/app/containers/Auth/index.tsx | <filename>src/app/containers/Auth/index.tsx
/**
*
* Auth
*
*/
import React from 'react';
import { Helmet } from 'react-helmet-async';
import { useSelector, useDispatch } from 'react-redux';
import styled from 'styled-components/macro';
import { useInjectReducer, useInjectSaga } from 'utils/redux-injectors';
impor... |
leodaiub/cybergamer-challenge | src/utils/dribbbleApi.ts | import axios from 'axios';
const dribbbleApi: any = axios.create({
baseURL:
'https://cors-anywhere.herokuapp.com/https://api.dribbble.com/v2/user',
});
dribbbleApi.interceptors.request.use(config => {
if (localStorage.getItem('access_token'))
config.headers.Authorization = `Bearer ${localStorage.access_tok... |
leodaiub/cybergamer-challenge | src/app/containers/Auth/saga.ts | <gh_stars>1-10
import { call, put, takeLatest } from 'redux-saga/effects';
import { actions } from './slice';
import api from 'utils/api';
import dribbbleApi from 'utils/dribbbleApi';
function* onCode() {
try {
let res = yield call(api.post, '/oauth/token');
localStorage.setItem('access_token', res.data.acce... |
leodaiub/cybergamer-challenge | src/app/components/DesignModal/index.tsx | <gh_stars>1-10
/**
*
* DesignModal
*
*/
import React from 'react';
import Modal from 'styled-react-modal';
import styled from 'styled-components';
interface Props {
isOpen: boolean;
handleModal: any;
avatar: string;
username: string;
project: any;
}
export function DesignModal(props: Props) {
return (... |
leodaiub/cybergamer-challenge | src/app/containers/Designs/saga.ts | import { call, put, takeLatest } from 'redux-saga/effects';
import { actions } from './slice';
import dribbbleApi from 'utils/dribbbleApi';
function* index() {
try {
const res = yield call(dribbbleApi.get, '/shots');
yield put(actions.getProjectsSuccess(res.data));
} catch {
yield put(actions.error());... |
leodaiub/cybergamer-challenge | src/app/components/Button/index.tsx | <reponame>leodaiub/cybergamer-challenge
/**
*
* Button
*
*/
import React from 'react';
import styled from 'styled-components/macro';
interface Props {}
export function Button(props: Props) {
return (
<Container type="button">
ENTRAR
<img src="arrow_right.png" alt="button"></img>
</Container>... |
leodaiub/cybergamer-challenge | src/app/containers/Designs/types.ts | /* --- STATE --- */
export interface DesignsState {
projects: any;
project: any;
loading: boolean;
error: boolean;
}
export type ContainerState = DesignsState;
|
leodaiub/cybergamer-challenge | src/app/containers/Designs/slice.ts | <filename>src/app/containers/Designs/slice.ts
import { PayloadAction } from '@reduxjs/toolkit';
import { createSlice } from 'utils/@reduxjs/toolkit';
import { ContainerState } from './types';
// The initial state of the Designs container
export const initialState: ContainerState = {
projects: [],
project: {},
lo... |
leodaiub/cybergamer-challenge | src/app/index.tsx | <filename>src/app/index.tsx
/**
*
* App
*
* This component is the skeleton around the actual pages, and should only
* contain code that should be seen on all pages. (e.g. navigation bar)
*/
import * as React from 'react';
import { Helmet } from 'react-helmet-async';
import { Switch, Route, BrowserRouter } from '... |
leodaiub/cybergamer-challenge | src/app/containers/Designs/index.tsx | /**
*
* Designs
*
*/
import React, { memo, useEffect, useState } from 'react';
import { Helmet } from 'react-helmet-async';
import { useSelector, useDispatch } from 'react-redux';
import styled from 'styled-components/macro';
import { useInjectReducer, useInjectSaga } from 'utils/redux-injectors';
import { reduce... |
leodaiub/cybergamer-challenge | src/app/containers/Auth/slice.ts | <filename>src/app/containers/Auth/slice.ts<gh_stars>1-10
import { createSlice } from 'utils/@reduxjs/toolkit';
import { ContainerState } from './types';
import { PayloadAction } from '@reduxjs/toolkit';
// The initial state of the Auth container
export const initialState: ContainerState = {
authenticated: false,
u... |
leodaiub/cybergamer-challenge | src/types/RootState.ts | <reponame>leodaiub/cybergamer-challenge
import { AuthState } from 'app/containers/Auth/types';
import { DesignsState } from 'app/containers/Designs/types';
// [IMPORT NEW CONTAINERSTATE ABOVE] < Needed for generating containers seamlessly
/*
Because the redux-injectors injects your reducers asynchronously somewhere... |
leodaiub/cybergamer-challenge | src/app/components/Header/index.tsx | /**
*
* Header
*
*/
import React from 'react';
import styled from 'styled-components/macro';
interface Props {
user: any;
}
export function Header(props: Props) {
return (
<Div>
<img src="logo.svg" alt="" height="50" width="150" />
<Div>
<p>{props.user.name}</p>
<img
... |
leodaiub/cybergamer-challenge | src/utils/api.ts | <reponame>leodaiub/cybergamer-challenge
import axios from 'axios';
const api: any = axios.create({
baseURL: 'https://cors-anywhere.herokuapp.com/https://dribbble.com',
});
api.interceptors.request.use(config => {
if (localStorage.getItem('access_token'))
config.headers.Authorization = `Bearer ${localStorage.ac... |
leodaiub/cybergamer-challenge | src/app/components/OAuthPopUp/index.tsx | import React, { useEffect, ReactChild } from 'react';
interface Props {
width?: number;
height?: number;
url: string;
title: string;
onClose: any;
onCode: any;
children?: ReactChild;
}
export default function OauthPopup({
width = 500,
height = 500,
url = '',
title = '',
children,
onClose,
... |
leodaiub/cybergamer-challenge | src/app/components/Design/index.tsx | /**
*
* Design
*
*/
import React from 'react';
import styled from 'styled-components/macro';
interface Props {
design: any;
handleModal: any;
}
export function Design(props: Props) {
return (
<Div onClick={props.handleModal}>
<img src={props.design.images.normal} alt="project"></img>
</Div>
... |
Tiamat-Tech/scatter.fm | src/models/FetchModel.ts | <reponame>Tiamat-Tech/scatter.fm
const FetchModel = Backbone.Model.extend({
initialize() {
this.set({
pagesFetched: [],
totalPages: 0,
lastPageFetched: 0,
isFetching: false
});
},
numPagesFetched() { return this.get("pagesFetched").length; },
fetch_scrobbles(username) {
if (... |
Tiamat-Tech/scatter.fm | src/views/FeedbackDialogView.ts | $("#feedback").click(() => $("#feedback-dialog").toggle());
$("#feedback-dialog .close").click(() => $("#feedback-dialog").hide());
|
Tiamat-Tech/scatter.fm | src/views/FetchThrobberView.ts | <gh_stars>10-100
const FetchThrobberView = Backbone.View.extend({
el: "#fetchThrobber",
render() {
if (fetchModel.get("isFetching")) {
let n = fetchModel.numPagesFetched();
let t = fetchModel.get('totalPages');
let status = `Fetching your scrobbles... ${n}/${t} pages done.`;
this.$("#fet... |
Tiamat-Tech/scatter.fm | src/models/RequestQueue.ts | <gh_stars>10-100
// Last.fm allows 5 reqs per second.
// I set this to 200ms per request, but the browser fell behind on requests and
// queued them up, them bursted through a whole lot of requests faster than
// allowed. I still got rate limited. So I've set it to 500ms, but I still get
// rate limited, but not as oft... |
Tiamat-Tech/scatter.fm | src/AppController.ts | <gh_stars>10-100
let appModel = new AppModel;
let fetchModel = new FetchModel;
let graphViewModel = new FlotScrobbleGraphViewModel;
let legendModel = new LegendModel;
let scrobbleCollection = new ScrobbleCollection;
let requestQueue = new RequestQueue({
max_n_reqs_in_progress: 4
});
appModel.on("change", function (m... |
Tiamat-Tech/scatter.fm | src/models/FlotScrobbleGraphViewModel.ts | <reponame>Tiamat-Tech/scatter.fm<filename>src/models/FlotScrobbleGraphViewModel.ts
const FlotScrobbleGraphViewModel = Backbone.Model.extend({
isDrawing: false,
isDrawn: false
});
|
Tiamat-Tech/scatter.fm | src/AppRouter.ts | let AppRouter = Backbone.Router.extend({
routes: {
"user/:user": "user",
"user/:user/": "user",
"user/:user/filter/:searchterm": "search"
}
});
let router = new AppRouter;
router.on("route:user", user => appModel.set({ user }));
router.on("route:search", (user, filterTerm) =>
appModel.set({
user... |
Tiamat-Tech/scatter.fm | src/models/ScrobbleCollection.ts | const Scrobble = Backbone.Model.extend({
artist() { return this.get("artist"); },
album() { return this.get("album"); },
track() { return this.get("track"); },
date() { return this.get("date"); },
image() { return this.get("image"); }
});
const ScrobbleCollection = Backbone.Collection.extend({
model: Scrob... |
Tiamat-Tech/scatter.fm | src/views/LegendView.ts | const LegendView = Backbone.View.extend({
el: "#legend_wrap",
render() {
this.$("li").remove();
let artistColors = legendModel.get("artistColors");
for (let artist in artistColors) {
let color = artistColors[artist];
if (color.color !== "gray") {
$("<li>")
.text(`${artist} ... |
Tiamat-Tech/scatter.fm | src/models/AppModel.ts | <gh_stars>10-100
// Global state that I couldn't find a more specific place for
// It's all used to form the path of the URL.
const AppModel = Backbone.Model.extend({
user() { return this.get("user"); },
initialize() {
this.set({ user: null });
this.set({ filterTerm: "" });
},
filterRegex() { return new... |
Tiamat-Tech/scatter.fm | src/models/Request.ts | const LastFMRequest = Backbone.Model.extend({
run() {
return $.ajax({
url: "https://ws.audioscrobbler.com/2.0/",
data: {
method: "user.getrecenttracks",
user: this.get("user"),
api_key: "<KEY>",
format: "json",
limit: "200",
page: this.get("page")
... |
Tiamat-Tech/scatter.fm | src/views/FilterBoxView.ts | <gh_stars>10-100
const FilterBoxView = Backbone.View.extend({
el: "#searchForm",
render(isDrawn) {
if (isDrawn) {
this.$el.fadeIn(1000);
} else {
this.$el.hide();
}
},
val() { return $("#search").val(); }
});
const filterBoxView = new FilterBoxView;
graphViewModel.on("change:isDrawn", ... |
Tiamat-Tech/scatter.fm | src/index.ts | $("#userForm").submit(function (e) {
e.preventDefault();
let username = $("#userInput").val();
document.location.href = `graph.html#/user/${username}`;
});
|
Tiamat-Tech/scatter.fm | src/views/UsernameView.ts | <reponame>Tiamat-Tech/scatter.fm
const UsernameView = Backbone.View.extend({
render() {
let user = appModel.get("user");
$(".user_link").text(user);
$(".user_link").attr("href", `http://www.last.fm/user/${user}`);
}
});
const usernameView = new UsernameView;
appModel.on("change:user", () => usernameVie... |
Tiamat-Tech/scatter.fm | src/views/DrawingThrobberView.ts | const DrawingThrobberView = Backbone.View.extend({
render() {
if (graphViewModel.get("isDrawing")) {
$("#drawingThrobber").show();
$("#drawStatus").text(`${scrobbleCollection.size()} scrobbles`);
} else {
$("#drawingThrobber").hide();
}
}
});
const drawingThrobberView = new DrawingThr... |
Tiamat-Tech/scatter.fm | src/views/ShareDialogView.ts | $("#share_link").click(() => $("#share_link").select());
$("#share_link").val(document.URL);
$(window).on("hashchange", () => $("#share_link").val(document.URL));
$("#share-btn").click(() => $("#share-dialog").toggle());
$("#share-dialog .close").click(() => $("#share-dialog").hide());
|
yjhatfdu/WebVR_MMD | app/HTTP.ts | /**
* Created by yjh on 16/1/29.
*/
///<reference path='../lib/Promise.d.ts'/>
export class Request{
open(url,method='GET',params={},headers={},postObject=null,type?,onload=function(content){},onerror=function(err){},onprogress=function(progress){}){
let x=new XMLHttpRequest();
let query=[];... |
yjhatfdu/WebVR_MMD | app/Material.ts | <gh_stars>0
/**
* Created by yjh on 16/3/30.
*/
import {PMDLoader} from "./PMDLoader";
export function getMaterial(loader:PMDLoader){
let materialList=[];
let pmdPath=loader.url;
let pathParts=pmdPath.split('/');
pathParts=pathParts.slice(0,pathParts.length-1);
pmdPath=pathParts.join('/');
for... |
yjhatfdu/WebVR_MMD | test/script/test.ts | <gh_stars>0
/**
* Created by yjh on 16/3/30.
*/
///<reference path="../../typings/threejs/three.d.ts"/>
import {MMD} from '../../app/MMD'
import Vector3 = THREE.Vector3;
let scene=new THREE.Scene();
let camera=new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000 );
var renderer = new TH... |
yjhatfdu/WebVR_MMD | app/PMDLoader.ts | /**
* Created by yjh on 16/3/30.
*/
/**
* Created by yjh on 16/3/28.
*/
let size_Int8 = Int8Array.BYTES_PER_ELEMENT;
let size_Uint8 = Uint8Array.BYTES_PER_ELEMENT;
let size_Uint16 = Uint16Array.BYTES_PER_ELEMENT;
let size_Uint32 = Uint32Array.BYTES_PER_ELEMENT;
let size_Float32 = Float32Array.BYTES_PER_ELEMENT;... |
yjhatfdu/WebVR_MMD | app/Model.ts | <reponame>yjhatfdu/WebVR_MMD
import {PMDLoader} from "./PMDLoader";
/**
* Created by yjh on 16/3/30.
*/
///<reference path="../typings/threejs/three.d.ts"/>
export class MMDModel extends THREE.BufferGeometry{
loader:PMDLoader;
positionBuffer:THREE.BufferAttribute;
oriPositionArray:Float32Array;
c... |
yjhatfdu/WebVR_MMD | app/MMD.ts | import {PMDLoader} from "./PMDLoader";
import {MMDModel} from "./Model";
import {getMaterial} from "./Material";
/**
* Created by yjh on 16/3/30.
*/
export class MMD extends THREE.Object3D{
static create(pmdFile):Promise<MMD>{
return new Promise(resolve=>{PMDLoader.load(pmdFile).then(loader=>{
... |
andyccc/nestjs-project | src/module/posts/dto/update-posts.dto.ts | <filename>src/module/posts/dto/update-posts.dto.ts
import { ApiProperty } from "@nestjs/swagger"
export class UpdatePostsDto {
@ApiProperty({ description: 'posts title' })
title: string
@ApiProperty({ description: 'posts content' })
content: string
}
|
andyccc/nestjs-project | src/common/utils/MD5.ts | <gh_stars>0
import * as crypto from 'crypto'
const PasswordSalt = '<PASSWORD>';
export function getSaltPassword(password): string {
var saltPassword = password + ':' + PasswordSalt;
// 加盐密码的md5值
var md5 = crypto.createHash('md5');
var resultPassword = md5.update(saltPassword).digest('hex');
return... |
andyccc/nestjs-project | src/common/utils/SnowflakeID.ts | /**
* 雪花 ID 生成器
* Date: 2021年11月25日14:20:21
* Version: 1.0.0
* A function for converting hex <-> dec w/o loss of precision.
* By <NAME> http://www.danvk.org/hex2dec.html
* @description js Number最大长度不超过17位,否则会出现精度丢失的问题
*/
export class SnowflakeID {
seq: number;
mid: number;
offset: any;
lastTime:... |
andyccc/nestjs-project | config/log4js.config.ts | <reponame>andyccc/nestjs-project<gh_stars>0
import * as path from 'path';
const baseLogPath = path.resolve(__dirname, '../../logs');
const log4jsConfig = {
appenders: {
console: { type: 'console' }, // 控制打印至控制台
// 统计日志
access: {
type: 'dateFile', // 写入文件格式,并按照日期分类
f... |
andyccc/nestjs-project | config/prod.env.ts | import { DbLogger } from 'src/common/utils/log4js';
import { ConnectionOptions } from 'typeorm';
export default {
// 端口
port: parseInt(process.env.PORT, 10) || 3000,
// 是否开启swagger
enableSwagger: true,
// 数据库配置
DATABASE_CONFIG: {
type: 'mysql',
host: '192.168.2.152',
por... |
andyccc/nestjs-project | src/app.module.ts | import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { PostsModule } from './module/posts/posts.module';
import { UserModule } from './module/user/user.module';
import { RedisModule } from 'nestjs-redis'
import { TypeOrmModule } fr... |
andyccc/nestjs-project | src/common/utils/request.format.ts | <reponame>andyccc/nestjs-project<gh_stars>0
import { getStandardDateTime } from "./timeutil"
import { Request } from "express"
export function toString(obj, tabCount = 2) {
let str = ''
let item
for (let key in obj) {
item = obj[key]
str += '\n'
for (let i = 0; i < tabCount; i++) {
... |
andyccc/nestjs-project | src/module/user/user.controller.ts | <reponame>andyccc/nestjs-project
import { Controller, Get, Post, Body, Patch, Param, Delete, HttpException, HttpStatus, UseGuards, Req, UseInterceptors, ClassSerializerInterceptor } from '@nestjs/common';
import { UserService } from './user.service';
import { CreateUserDto } from './dto/create-user.dto';
import { Updat... |
andyccc/nestjs-project | src/module/user/entities/user.entity.ts | <gh_stars>0
import { Exclude, Transform } from "class-transformer";
import { MyBaseEntity } from "src/common/entities/base_entity";
import { getStandardDateTime } from "src/common/utils/timeutil";
import { Column, Entity, UpdateDateColumn } from "typeorm";
@Entity()
export class UserEntity extends MyBaseEntity {
... |
andyccc/nestjs-project | src/module/posts/posts.providers.ts | import { Connection } from "typeorm";
import { PostsEntity } from "./entities/posts.entity";
export const postsProviders = [
{
provide: 'POSTS_REPOSITORY',
useFactory: (connection: Connection) => connection.getRepository(PostsEntity),
inject: ['DATABASE_CONNECTION']
}
] |
andyccc/nestjs-project | src/common/utils/log4js.ts | // 目前把实例化类配置放在 src\utils\log4js.ts 中
import * as Path from 'path';
import * as Log4js from 'log4js';
import * as Util from 'util';
import * as Moment from 'moment'; // 处理时间的工具
import * as StackTrace from 'stacktrace-js';
import Chalk from 'chalk';
import log4jsConfig from 'config/log4js.config';
import { QueryRunner }... |
andyccc/nestjs-project | src/module/posts/dto/page-posts.dto.ts | <filename>src/module/posts/dto/page-posts.dto.ts<gh_stars>0
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
import { MyPageDto } from "src/common/page/page.dto";
export class PagePostsDto extends MyPageDto {
@ApiPropertyOptional({ description: 'title fuzzy query' })
title: string
} |
andyccc/nestjs-project | src/common/controller/baes.controller.ts | <reponame>andyccc/nestjs-project
import { ClassSerializerInterceptor, HttpException, HttpStatus, UseInterceptors } from "@nestjs/common";
import { ApiErrorCode } from "../enums/api-error-code.enum";
import { ApiException } from "../exceptions/api.exception";
@UseInterceptors(ClassSerializerInterceptor)
export abstract... |
andyccc/nestjs-project | src/module/posts/dto/create-posts.dto.ts | <reponame>andyccc/nestjs-project<filename>src/module/posts/dto/create-posts.dto.ts
import { ApiProperty } from "@nestjs/swagger"
import { IsNotEmpty, Length } from "class-validator"
export class CreatePostsDto {
@ApiProperty({ description: 'posts title' })
@IsNotEmpty({ message: "title can't be empty" })
@... |
andyccc/nestjs-project | src/module/posts/posts.controller.ts | <reponame>andyccc/nestjs-project
import { Body, Request, Controller, Delete, Get, HttpException, HttpStatus, Param, Post, Put, Query, UseGuards, UsePipes, ValidationPipe, Req } from '@nestjs/common';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { BaseController } from 'src/common/controller/baes.cont... |
andyccc/nestjs-project | src/module/user/user.module.ts | <reponame>andyccc/nestjs-project
import { Module } from '@nestjs/common';
import { UserService } from './user.service';
import { UserController } from './user.controller';
import { DatabaseModule } from 'src/common/db/database.module';
import { userProviders } from './user.providers';
import { PassportModule } from '@n... |
andyccc/nestjs-project | src/common/db/database.providers.ts | <filename>src/common/db/database.providers.ts
import { ConfigService } from '@nestjs/config'
import { createConnection } from 'typeorm'
import { environment } from 'config';
export const databaseProviders = [
{
provide: 'DATABASE_CONNECTION',
useFactory: async () => await createConnection(environm... |
andyccc/nestjs-project | src/common/filters/any-exception.filter.ts | <gh_stars>0
import { ExceptionFilter, Catch, ArgumentsHost, HttpException, HttpStatus } from '@nestjs/common';
import { ApiErrorCode } from '../enums/api-error-code.enum';
import { ApiException } from '../exceptions/api.exception';
import { Logger } from '../utils/log4js';
import { formatReq } from '../utils/request.fo... |
andyccc/nestjs-project | src/common/decorator/customize.ts | <reponame>andyccc/nestjs-project<filename>src/common/decorator/customize.ts
import { SetMetadata } from '@nestjs/common'
export const NoAuth = () => SetMetadata('no-auth', true);
|
andyccc/nestjs-project | src/module/posts/entities/posts.entity.ts | import { MyBaseEntity } from "src/common/entities/base_entity";
import { Column, Entity } from "typeorm";
@Entity()
export class PostsEntity extends MyBaseEntity {
@Column({
name: 'title',
length: 200,
comment: 'title field'
})
title: string
@Column({
name: 'content',... |
andyccc/nestjs-project | src/common/entities/base_entity.ts | import { getStandardDateTime } from "../utils/timeutil";
import { Column, CreateDateColumn, PrimaryColumn, UpdateDateColumn } from "typeorm";
import { Exclude, Transform, TransformFnParams, Type } from "class-transformer";
// @Entity()
export class MyBaseEntity {
// @Column({
// type: 'varchar',// mysql sq... |
andyccc/nestjs-project | src/common/utils/timeutil.ts | import * as moment from "moment";
export function getStandardDateTime(date) {
return moment(date).format('YYYY-MM-DD HH:mm:ss')
} |
andyccc/nestjs-project | src/common/service/base.service.ts | <gh_stars>0
import { Repository, SelectQueryBuilder } from "typeorm";
import { MyPageDto, PageData } from "../page/page.dto";
export class BaseService<T> {
async findListByPage(pageDto: MyPageDto, repository: Repository<T>, queryFn: (query) => (SelectQueryBuilder<T>)) {
let limit = Math.min(Math.max(0, p... |
andyccc/nestjs-project | src/common/interceptors/transform.interceptor.ts | /**
* see more detail at : https://docs.nestjs.com/interceptors#interceptors
*/
import { CallHandler, ExecutionContext, HttpCode, Injectable, NestInterceptor } from "@nestjs/common";
import { map, Observable } from "rxjs";
import { ApiErrorCode } from "../enums/api-error-code.enum";
import { Logger } from "../utils/... |
andyccc/nestjs-project | src/module/posts/posts.service.ts | <reponame>andyccc/nestjs-project
import { Inject, Injectable, Post } from '@nestjs/common';
import { min } from 'class-validator';
import { PageData } from 'src/common/page/page.dto';
import { BaseService } from 'src/common/service/base.service';
import { snid } from 'src/common/utils/SnowflakeID';
import { Repository ... |
andyccc/nestjs-project | src/module/user/dto/create-user.dto.ts | import { Equals, IsEmail, IsEmpty, IsNotEmpty, Length, Matches, ValidateIf } from "class-validator"
export class CreateUserDto {
@ValidateIf(obj => { return obj.username ? true : false })
@Length(2, 20, { message: 'username length is in 2~20' })
readonly username: string
@Matches(/(?=.*[0-9])(?=.*[a-... |
andyccc/nestjs-project | src/module/user/local.strategy.ts | import { HttpException, HttpStatus, Injectable } from "@nestjs/common";
import { Strategy } from 'passport-local'
import { PassportStrategy } from '@nestjs/passport'
import { UserService } from "./user.service";
@Injectable()
export class LocalStrategy extends PassportStrategy(Strategy) {
constructor(private read... |
andyccc/nestjs-project | src/common/enums/api-error-code.enum.ts | export enum ApiErrorCode {
TIMEOUT = -1, // 系统繁忙
SUCCESS = 1, // 成功
FAILED = 0, // 失败
USER_ID_INVALID = 10001,// 用户id无效
USER_ACCOUNT_REGISTERED = 1002,// 用户账号已注册
USER_ACCOUNT_OR_PASSWORD_INVALID = 10003,// 用户名或者密码无效
USER_PASSWORD_TWICE_NOT_SAME = 10004,// 用户密码两次不一致
PARAM_IS_MISSING = 2... |
andyccc/nestjs-project | src/common/page/page.dto.ts | import { DefaultValuePipe } from "@nestjs/common"
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger"
export class MyPageDto {
@ApiPropertyOptional({ description: 'default is 10' })
limit: number = 10
@ApiPropertyOptional({ description: 'default is 1 ' })
page: number = 1
}
export inter... |
andyccc/nestjs-project | src/module/user/dto/login-user.dto.ts | import { IsNotEmpty, Length } from "class-validator"
export class LoginUserDto {
@IsNotEmpty({ message: 'username can‘t be empty' })
@Length(1, 20, { message: 'username length is in 1~20' })
username: string
@IsNotEmpty({ message: 'password can‘t be empty' })
@Length(6, 20, { message: 'username l... |
andyccc/nestjs-project | src/module/user/jwt.strategy.ts | import { Injectable } from "@nestjs/common";
import { Strategy, ExtractJwt } from 'passport-jwt';
import { PassportStrategy } from '@nestjs/passport';
import { JwtService } from '@nestjs/jwt';
import { JwtConstants } from "config/constatns";
@Injectable()
export class JwtStrategy extends PassportStrategy(Strategy) {... |
andyccc/nestjs-project | config/index.ts |
import * as dev from './dev.env';
import * as prod from './prod.env';
const envconfigs = {
development: dev,
production: prod,
};
const environment = envconfigs[process.env.NODE_ENV || 'development']
export { environment };
|
andyccc/nestjs-project | src/module/user/user.service.ts | import { Inject, Injectable } from '@nestjs/common';
import { BaseService } from 'src/common/service/base.service';
import { Repository } from 'typeorm';
import { CreateUserDto } from './dto/create-user.dto';
import { UpdateUserDto } from './dto/update-user.dto';
import { UserEntity } from './entities/user.entity';
im... |
andyccc/nestjs-project | config/dev.env.ts | <gh_stars>0
import { DbLogger } from 'src/common/utils/log4js';
import { ConnectionOptions } from 'typeorm';
export default {
// 端口
port: parseInt(process.env.PORT, 10) || 3000,
// 是否开启swagger
enableSwagger: true,
// 数据库配置
DATABASE_CONFIG: {
type: 'mysql',
host: '192.168.2.152'... |
andyccc/nestjs-project | src/common/guard/role.auth.guard.ts | <gh_stars>0
import { Injectable, CanActivate, ExecutionContext } from '@nestjs/common';
import { Observable } from 'rxjs';
import { Reflector } from '@nestjs/core';
import { AuthGuard, IAuthGuard } from '@nestjs/passport';
@Injectable()
export class RoleAuthGuard implements CanActivate {
constructor(private readon... |
andyccc/nestjs-project | config/constatns.ts | <reponame>andyccc/nestjs-project
export const JwtConstants = {
secret: 'andyccc@2021'
} |
andyccc/nestjs-project | src/common/filters/http-exceptin.filter.ts | import { ArgumentsHost, Catch, ExceptionFilter, HttpException } from "@nestjs/common";
import { ApiErrorCode } from "../enums/api-error-code.enum";
import { ApiException } from "../exceptions/api.exception";
import { getStandardDateTime } from "../utils/timeutil";
// global exception returned(filter)
@Catch(HttpExcept... |
andyccc/nestjs-project | src/main.ts | import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
// import global valid pipe to check submit params
import { ValidationPipe } from './common/pipes/validation.pipe'
// import global filter
import { HttpExceptionFilter } from './common/filters/http-exceptin.filter'
// import globa... |
klabacher/Presos | src/Pages/Tabs/Ponto.tsx | import React, { useState } from 'react';
import { makeStyles, createMuiTheme } from '@material-ui/core/styles';
import TextField from '@material-ui/core/TextField';
import { Text, View, ProgressCircle, Button } from 'react-desktop/windows';
import { AxiosError, AxiosPromise } from 'axios';
import { instance } from '../... |
klabacher/Presos | src/App.tsx | <gh_stars>0
import React from 'react';
import { BrowserRouter as Router, Switch, Route } from 'react-router-dom';
import './App.global.css';
import Navbar from './Pages/Navbar';
const Main = () => {
return (
<div>
<Navbar theme="dark" />
</div>
);
};
export default function App() {
return (
<... |
klabacher/Presos | src/vault.tsx | <reponame>klabacher/Presos
/* eslint-disable class-methods-use-this */
/* eslint-disable promise/always-return */
import { instance } from './utils';
class Vault {
async login(
username: string,
password: string,
cbsucess: { (): void; (arg0: { err: boolean; data: any }): void },
cberror: { (err: any)... |
klabacher/Presos | src/Pages/Navbar.tsx | import React, { Component } from 'react';
import { NavPane, NavPaneItem, Text } from 'react-desktop/windows';
import Novo from './Tabs/Novo';
import Ponto from './Tabs/Ponto';
import Home from './Tabs/Home';
export default class Title extends Component {
constructor() {
super();
this.state = {
selecte... |
klabacher/Presos | src/components/grettings.tsx | <gh_stars>0
import React, { useState, useEffect } from 'react';
import { makeStyles, createMuiTheme } from '@material-ui/core/styles';
import TextField from '@material-ui/core/TextField';
import './grettings.scss';
import {
Text,
View,
ProgressCircle,
Button,
Checkbox,
TextInput,
} from 'react-desktop/win... |
klabacher/Presos | src/components/crime.tsx | import React from 'react';
import { Checkbox, TextInput } from 'react-desktop/windows';
import CrimesJson from '../Pages/Tabs/stepsCon.json';
import { fixlabel } from '../utils';
export default function crime({ state, activeStep, props, radioCB, TextCB }) {
console.log(state)
return (
<div
key="10"
... |
klabacher/Presos | src/Pages/Tabs/Novo.tsx | <filename>src/Pages/Tabs/Novo.tsx
/* eslint-disable react/prop-types */
/* eslint-disable react/destructuring-assignment */
/* eslint-disable react/no-unused-state */
import React, { Component } from 'react';
import { Text, View, ProgressCircle, Button } from 'react-desktop/windows';
import Stepper from '@material-ui/... |
klabacher/Presos | src/utils.tsx | <reponame>klabacher/Presos
import axios from 'axios';
function fixlabel(label: string) {
return label.replaceAll(' ', '_');
}
const instance = axios.create({
baseURL: 'http://127.0.0.1:3333',
timeout: 10000,
headers: { 'X-Custom-Header': 'foobar' },
});
export { fixlabel, instance };
|
klabacher/Presos | src/Pages/Tabs/Home.tsx | <gh_stars>0
import React, { useState, useEffect } from 'react';
import { makeStyles, createMuiTheme } from '@material-ui/core/styles';
import TextField from '@material-ui/core/TextField';
import {
Text,
View,
ProgressCircle,
Button,
Checkbox,
TextInput,
} from 'react-desktop/windows';
import swal from 'swee... |
opencdk8s/cdk8s-opendistro-for-elasticsearch | test/hello.test.ts | <filename>test/hello.test.ts
import { Chart, Testing } from 'cdk8s';
import * as es from '../src/index';
test('elasticsearch', () => {
const app = Testing.app();
const chart = new Chart(app, 'test');
new es.MyElasticSearch(chart, 'es', {
name: 'elasticsearch',
});
expect(Testing.synth(chart)).toMatchSnap... |
opencdk8s/cdk8s-opendistro-for-elasticsearch | src/constructs/kibana.ts | import * as cdk8s from 'cdk8s';
import { Construct } from 'constructs';
import { ResourceRequirements, convertQuantity } from '../util';
export interface KibanaOpts {
readonly name?: string;
readonly namespace?: string;
readonly kibanaImage?: string;
readonly kibanaReplicas?: number;
readonly kibanaResource... |
opencdk8s/cdk8s-opendistro-for-elasticsearch | src/index.ts | <filename>src/index.ts
import { Construct } from 'constructs';
import { MyClient } from './constructs/client';
import { MyData } from './constructs/data';
import { MyKibana } from './constructs/kibana';
import { MyMaster } from './constructs/master';
import { MyMisc } from './constructs/misc';
import { ResourceRequirem... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.