Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

Bhargav Bachina bbachi

💭
I may be slow to respond.
  • Rogers, AR
View GitHub Profile
View package.json
{
"name": "react-nodejs-example",
"version": "1.0.0",
"description": "example project react with nodejs",
"main": "server.js",
"scripts": {
"start": "node server.js",
"dev": "nodemon ./server.js localhost 3080"
},
"repository": {
View server.js
const express = require('express');
const path = require('path');
const app = express(),
bodyParser = require("body-parser");
port = 8080;
// place holder for the data
const users = [
{
firstName: "first1",
View package.json
{
"name": "api",
"version": "1.0.0",
"description": "example project react with nodejs",
"main": "server.js",
"scripts": {
"start": "node server.js",
"build": "webpack",
"dev": "nodemon ./server.js localhost 3080"
},
View server.js
const express = require('express');
const randomId = require('random-id');
const app = express(),
bodyParser = require("body-parser");
port = 8080;
// place holder for the data
const users = [
{
id: "1",
View package.json
{
"name": "angular-nodejs-example",
"version": "1.0.0",
"description": "node server",
"main": "index.js",
"scripts": {
"start": "node server.js",
"build": "webpack",
"dev": "nodemon ./server.js localhost 3080",
"test": "echo \"Error: no test specified\" && exit 1"
View server.js
const express = require('express');
var bodyParser = require('body-parser');
const app = express(),
port = 8080;
const users = [];
app.use(bodyParser.urlencoded());
app.use(bodyParser.json());
app.use(express.static(process.cwd()+"/my-app/dist/angular-nodejs-example/"));
View App.tsx
import './App.css';
import DrawingArea from './DrawingArea';
function App() {
return (
<>
<h1> Drawing Area</h1>
<div className="App drawing-area">
<DrawingArea />
</div>
View DrawingArea.tsx
import { Stage, Layer, Line } from 'react-konva';
import { useState, useRef } from 'react';
const DrawingArea = () => {
const [lines, setLines] = useState<any>([]);
const isDrawing = useRef(false);
const handleMouseDown = (e:any) => {
isDrawing.current = true;
View App.tsx
import './App.css';
function App() {
return (
<>
<h1> Drawing Area</h1>
<div className="App drawing-area">
</div>
</>
View App.js
import './App.css';
import DrawingArea from './DrawingArea';
function App() {
return (
<>
<h1> Drawing Area</h1>
<div className="App drawing-area">
<DrawingArea />