Skip to content

Instantly share code, notes, and snippets.

View hieptl's full-sized avatar
🎯
Focusing

Hiep Le hieptl

🎯
Focusing
View GitHub Profile
@hieptl
hieptl / meetings.js
Created December 3, 2021 04:10
meetings.js - server - get all meetings - Zoom Clone
app.get("/meetings/:id", (req, res) => {
const id = req.params.id;
const findMeetingsSql = "SELECT * FROM meeting WHERE created_by = ?";
dbConn.query(findMeetingsSql, [id], function (error, meetings) {
res.status(200).jsonp(meetings);
});
});
@hieptl
hieptl / meetings.js
Created December 3, 2021 04:08
meetings.js - server - create meeting - Zoom Clone
app.post("/meetings", (req, res) => {
const { name, uid, createdBy } = req.body;
if (!name || !uid) {
return res.status(200).jsonp({ message: "Please provide the meeting name and meeting uid" });
}
const meetings = [[name, uid, createdBy]];
const createMeetingSql = "INSERT INTO meeting (meeting_title, meeting_uid, created_by) VALUES ?";
dbConn.query(createMeetingSql, [meetings], function (error, insertedMeeting) {
if (insertedMeeting) {
res.status(200).jsonp({ insertId: insertedMeeting.insertId });
@hieptl
hieptl / user.js
Created December 3, 2021 04:05
user.js - server - create a new user - Zoom Clone
module.exports = function ({ app, dbConn }) {
app.post("/users/create", (req, res, next) => {
const { id, email, password, fullname, avatar } = req.body;
if (id && email && password && fullname, avatar) {
const findAccountByEmail = "SELECT * FROM user_account WHERE user_email = ?";
dbConn.query(findAccountByEmail, [email], function (error, account) {
if (account && account.length !== 0) {
res.status(200).jsonp({ message: 'The email existed in the system' });
} else {
const users = [[id, email, password, fullname, avatar]];
@hieptl
hieptl / auth.js
Created December 3, 2021 04:01
auth.js - server - Zoom Clone
module.exports = function ({ app, dbConn }) {
app.post("/login", (req, res) => {
const { email, password } = req.body;
if (email && password) {
const sql = "SELECT * FROM user_account WHERE user_email = ? AND user_password = ?";
dbConn.query(sql, [email, password], function (error, response) {
if (response && response.length !== 0) {
res.status(200).jsonp({ ...response[0] });
} else {
res.status(200).jsonp({ message: "Your username or password is not correct" });
@hieptl
hieptl / index.js
Created December 3, 2021 03:52
index.js - server - routes - Zoom Clone
const authRoutes = require("./auth");
const userRoutes = require("./users");
const meetingRoutes = require("./meetings");
module.exports = function ({ app, dbConn }) {
authRoutes({ app, dbConn });
userRoutes({ app, dbConn });
meetingRoutes({ app, dbConn });
};
@hieptl
hieptl / index.js
Created December 3, 2021 03:50
index.js - server - Zoom Clone
require("dotenv").config();
const bodyParser = require("body-parser");
const cors = require("cors");
const express = require("express");
const mysql = require("mysql2");
const path = require("path");
const PORT = process.env.PORT || 8080;
const app = express();
@hieptl
hieptl / zoom.sql
Created December 3, 2021 03:43
zoom.sql - Zoom Clone
DROP DATABASE IF EXISTS zoom;
CREATE DATABASE zoom;
USE zoom;
CREATE TABLE user_account (
id VARCHAR(255) NOT NULL,
user_email VARCHAR(255) NOT NULL,
user_password VARCHAR(255) NOT NULL,
@hieptl
hieptl / CometChatUI.kt
Last active December 1, 2021 08:25
CometChatUI.kt - Instagram Clone Android Kotlin
class CometChatUI : AppCompatActivity(), BottomNavigationView.OnNavigationItemSelectedListener, OnAlertDialogButtonClickListener {
private var loggedInUsername: TextView? = null
...
private fun initViewComponent() {
...
/* FeatureRestriction.isUserSettingsEnabled(object : FeatureRestriction.OnSuccessListener{
override fun onSuccess(p0: Boolean) {
userSettingsEnabled = p0
activityCometChatUnifiedBinding?.bottomNavigation?.menu?.findItem(R.id.menu_more)?.isVisible = p0
@hieptl
hieptl / post.js
Created November 23, 2021 07:00
post.js - Instagram Clone React Native
import React from 'react';
import { View, Image, Text, StyleSheet, TouchableOpacity, Platform } from 'react-native';
import Video from 'react-native-video';
import VideoPlayer from 'react-native-video-controls';
const Post = (props) => {
const { post, toggleLike, toggleFollow, onItemClicked, isFollowHidden } = props;
const onHeartClicked = () => {
toggleLike(post);
@hieptl
hieptl / profilepost.js
Created November 23, 2021 06:56
profilepost.js - Instagram Clone React Native
import React from 'react';
import { View, Image, StyleSheet, Platform, TouchableOpacity } from 'react-native';
import Video from 'react-native-video';
import VideoPlayer from 'react-native-video-controls';
const ProfilePost = (props) => {
const { post, onItemClicked } = props;
if (!post) {
return <></>;