Skip to content

Instantly share code, notes, and snippets.

Avatar

Rajitha Gunathilake RizkyRajitha

View GitHub Profile
View login
//bkend
router.post("/login1", function(req, res, next) {
passport.authenticate("local", function(err, user, info) {
console.log("ppppp");
if (err) {
console.log("error no user");
return next(err);
}
View registration
//frontend
import React, { Component } from "react";
import jsonwebtoken from "jsonwebtoken";
import { Redirect } from "react-router-dom";
import axios from "axios";
class Register extends Component {
state = {
email: "",
View server.js
//import all the dependencies
const chatkit = require("@pusher/chatkit-server");
const express = require("express");
const bp = require("body-parser");
const cors = require("cors");
//make our server
const app = express();
//enable cors
app.use(cors());
//enable body parser
View client.js
//import all the dependencies
const prompt = require("prompt");
const { ChatManager, TokenProvider } = require("@pusher/chatkit-client");
const axios = require("axios");
const { JSDOM } = require("jsdom");
const readline = require("readline");
const ora = require('ora');
const spinner = ora()
View app.svelte
<script>
import Home from "./home.svelte";//importing app component from home.svelt
</script>
<Home />
View appwritequiestions.md

1 . appwrite only for testing purpose only , after devoloping the frontend we can wire it with our own backend . am i correct

2 .i dont understand that, how to handle my requiest . like lets say i want to make a login which is backed by appwrite self hosted server . what i usually do is make a post request to my backend server and the i will get the payload , base on that payload i can decide wheather to log this user or not

something like

{
View dropdaownnavbar.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
</head>
<style>
View supplyAd.js
const express = require("express");
var router = express.Router();
var ObjectId = require("mongoose").Types.ObjectId;
var { SupplyAd } = require("../models/supplyAd");
router.get("/", (req, res) => {
SupplyAd.find({
eDate: {
// mechchrai aulthen dmme
View promiseall.js
var files = req.files;
var promisarr = [];//initialize promises array
function multiplefiles3(resobj) {
console.log(resobj.originalname);
var params = {
Bucket: "******",
Key: resobj.originalname,
Body: resobj.buffer
};
return s3bucket.upload(params).promise();
View forloop.js
var arr1 = [1, 2, 3, 4];
var arr2 = [7, 8, 9, 1];
loop1: for (let element1 of arr1) {//define a breakpoint
for (let element2 of arr2) {
console.log(element1, " ", element2);
if (element1 === element2) {
console.log("duplicate numbers");
break loop1;//if a specific condition is met , break the loop