Skip to content

Instantly share code, notes, and snippets.

@kuc-arc-f
kuc-arc-f / package.json
Created March 29, 2022 02:56
exceljs , load data sample react
{
"name": "react_ts",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@types/jest": "^26.0.15",
"@types/node": "^12.0.0",
@kuc-arc-f
kuc-arc-f / apiGateway.ts
Created January 21, 2022 07:52
Serverless Framework + TypeScript, CORS sample
import type { APIGatewayProxyEvent, APIGatewayProxyResult, Handler } from "aws-lambda"
import type { FromSchema } from "json-schema-to-ts";
type ValidatedAPIGatewayProxyEvent<S> = Omit<APIGatewayProxyEvent, 'body'> & { body: FromSchema<S> }
export type ValidatedEventAPIGatewayProxyEvent<S> = Handler<ValidatedAPIGatewayProxyEvent<S>, APIGatewayProxyResult>
export const formatJSONResponse = (response: Record<string, unknown>) => {
return {
statusCode: 200,
headers: {
@kuc-arc-f
kuc-arc-f / graphql.js
Created January 18, 2022 04:47
Serverless Framework, apollo-server sample
const { ApolloServer, gql } = require('apollo-server-lambda');
// typeDefs
const typeDefs = gql`
type Query {
hello: String
}
`;
const resolvers = {
@kuc-arc-f
kuc-arc-f / app.js
Created January 18, 2022 02:31
Serverless Framework express, prisma (mysql) sample
const serverless = require('serverless-http');
const express = require('express');
const indexRouter = require('./routes/index');
const usersRouter = require('./routes/users');
const app = express();
app.use('/', indexRouter);
app.use('/users',usersRouter);
module.exports = app;
@kuc-arc-f
kuc-arc-f / LibMongo.js
Last active January 16, 2022 10:18
Serverless Framework + express, mongoDB atlas sample
'use strict';
const MongoClient = require('mongodb').MongoClient;
const Config = require('../config.js');
const CFG = Config.getConfig();
//console.log( CFG.MONGODB_URL );
//console.log( CFG.MONGODB_DB_NAME );
const URI = CFG.MONGODB_URL + "?retryWrites=true&w=majority";
const DbName = CFG.MONGODB_DB_NAME;
module.exports.getClient = async () => {
// console.log("IS_OFFLINE= ", process.env.IS_OFFLINE);
@kuc-arc-f
kuc-arc-f / app.js
Created January 16, 2022 03:15
Serverless Framework + express, deploy sample
const serverless = require('serverless-http');
const express = require('express');
const indexRouter = require('./routes/index');
const usersRouter = require('./routes/users');
const app = express();
app.use('/', indexRouter);
app.use('/users',usersRouter);
//module.exports = app;
@kuc-arc-f
kuc-arc-f / xls6.tsx
Created January 15, 2022 04:07
React + ExcelJS, XLS templete read, sample
/* XLS templete, read */
import React from 'react'
const ExcelJS = require('exceljs');
import axios from 'axios'
interface IProps {
history:string[],
}
//
class Test extends React.Component<IProps> {
@kuc-arc-f
kuc-arc-f / xls2.tsx
Created January 14, 2022 00:46
Excel(exceljs) sample, react 17
/* jsPdf , japan lang sample */
import React from 'react'
const ExcelJS = require('exceljs');
interface IProps {
history:string[],
}
//
class Test extends React.Component<IProps> {
constructor(props: any) {
@kuc-arc-f
kuc-arc-f / serverless.yml
Last active January 13, 2022 02:43
serverless.yml, Serverless Framework local sample
service: service2
custom:
dynamodb:
stages:
- dev
start:
port: 8000
inMemory: true
migrate: true
@kuc-arc-f
kuc-arc-f / serverless.yml
Created January 13, 2022 00:12
serverless.yml, Serverless Framework test sample
service: service1
#frameworkVersion: '2'
provider:
name: aws
runtime: nodejs12.x
region: ap-northeast-1
stage: dev