GithubHelp home page GithubHelp logo

leancloud / node-js-getting-started Goto Github PK

View Code? Open in Web Editor NEW
133.0 35.0 118.0 170 KB

LeanEngine Node.js getting started.

Home Page: https://leancloud.cn/docs/leanengine_overview.html

JavaScript 79.72% CSS 1.98% EJS 18.30%
leanengine leancloud

node-js-getting-started's Introduction

Node.js Getting started

A simple Node.js application based on express for LeanEngine Node.js runtime.

Documentation

Contribute

  • Don't commit package-lock.json, because of this is a template project, we hope users can lock their dependencies when they init projects for the first time.

node-js-getting-started's People

Contributors

aisk avatar feisuzhu avatar heziqiang avatar hjiang avatar juvenn avatar jysperm avatar leeyeh avatar lzwjava avatar myleslee avatar sdjcw avatar sparanoid avatar wangxiao avatar weakish avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-js-getting-started's Issues

可以加一个flash中间件的例子么

connect-flashflash这两个包都试过了。

router.get('/login', (req, res) => {
	// 判断用户是否已经登录
	if (req.currentUser) {
		// 如果已经登录,发送当前登录用户信息。
		res.redirect('/users/profile')
	} else {
		// 没有登录,跳转到登录页面。
		console.log(req)
		res.render('login', {message: req.flash('error')})
	}
})
// 处理登录请求(可能来自登录界面中的表单)
router.post('/login', (req, res) => {
	AV.User.logIn(req.body.emailOrPhone, req.body.password).then((user) => {
		user.set('lastLoginIP', req.headers['x-real-ip'])
		user.save()
		res.saveCurrentUser(user) // 保存当前用户到 Cookie
		res.redirect('/users/profile') // 跳转到个人资料页面
	}, (error) => {
		//登录失败,跳转到登录页面
		console.log(error.code)
		req.flash('error', error.code)
		return res.redirect('/users/login')
	})
})
<!DOCTYPE HTML>
<html>
<head>
    <title>登陆</title>
</head>
<body>
<% if (flash) { %>
<p><%= flash.message %></p>
<% } %>
<form action="/users/login" method="post">
    <label>用户名/邮箱:</label>
    <input type="text" name="emailOrPhone" autocomplete="on" placeholder="用户名/邮箱">
    <label>密码:</label>
    <input type="password" name="password" autocomplete="off" placeholder="密码">
    <input type="submit" value="登陆"/>
</form>
</body>
</html>
const express = require('express')
const cookieParser = require('cookie-parser')
const cookieSession = require('cookie-session')
const AV = require('leanengine')
const flash = require('flash')

app.use(AV.Cloud.CookieSession({ secret: 'my secret', maxAge: 3600000, fetchUser: true }))
app.use(cookieSession({ name: 'session', keys: ['key1', 'key2'] }))
app.use(flash())

代码如上所述,看过文档中关于session的描述了,但是还是没能配置成功。

不能创建项目

美国节点项目

`xirtam:node xirtam$ git clone [email protected]:leancloud/node-js-getting-started.git

Cloning into 'node-js-getting-started'...

ssh: connect to host github.com port 22: Connection refused

fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
`

lean new返回401

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.